diff --git a/app/(application)/_layout.tsx b/app/(application)/_layout.tsx
index 877e2e0..a1664d0 100644
--- a/app/(application)/_layout.tsx
+++ b/app/(application)/_layout.tsx
@@ -6,18 +6,22 @@ import HeaderRightGroupList from "@/components/group/headerGroupList";
import HeaderMemberList from "@/components/member/headerMemberList";
import HeaderRightPositionList from "@/components/position/headerRightPositionList";
import HeaderRightProjectList from "@/components/project/headerProjectList";
+import Text from "@/components/Text";
+import ToastCustom from "@/components/toastCustom";
import { Headers } from "@/constants/Headers";
+import Styles from "@/constants/Styles";
import { apiReadOneNotification } from "@/lib/api";
import { pushToPage } from "@/lib/pushToPage";
import store from "@/lib/store";
import { useAuthSession } from "@/providers/AuthProvider";
+import firebase from '@react-native-firebase/app';
import { Redirect, router, Stack } from "expo-router";
import { StatusBar } from 'expo-status-bar';
import { useEffect } from "react";
-import { Text } from "react-native";
+import { View } from "react-native";
import { Easing, Notifier } from 'react-native-notifier';
+import Toast from "react-native-toast-message";
import { Provider } from "react-redux";
-import firebase from '@react-native-firebase/app';
export default function RootLayout() {
const { token, decryptToken, isLoading } = useAuthSession()
@@ -122,6 +126,7 @@ export default function RootLayout() {
/>
+
)
}
diff --git a/app/index.tsx b/app/index.tsx
index eea348b..c9db8e4 100644
--- a/app/index.tsx
+++ b/app/index.tsx
@@ -1,11 +1,11 @@
import ViewLogin from "@/components/auth/viewLogin";
import ViewVerification from "@/components/auth/viewVerification";
+import Text from '@/components/Text';
+import ToastCustom from "@/components/toastCustom";
import { requestPermission } from "@/lib/useNotification";
import { useAuthSession } from "@/providers/AuthProvider";
import { Redirect } from "expo-router";
import { useEffect, useState } from "react";
-import { View } from "react-native";
-import Text from '@/components/Text';
export default function Index() {
const [isValid, setValid] = useState(false)
diff --git a/bun.lockb b/bun.lockb
index 0a36987..3bae3c9 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/components/auth/viewLogin.tsx b/components/auth/viewLogin.tsx
index 6c0b409..c98239f 100644
--- a/components/auth/viewLogin.tsx
+++ b/components/auth/viewLogin.tsx
@@ -2,11 +2,13 @@ import Styles from "@/constants/Styles"
import { apiCheckPhoneLogin, apiSendOtp } from "@/lib/api"
import AsyncStorage from "@react-native-async-storage/async-storage"
import { useState } from "react"
-import { Image, SafeAreaView, ToastAndroid, View } from "react-native"
+import { Image, SafeAreaView, View } from "react-native"
+import Toast from "react-native-toast-message"
import { ButtonForm } from "../buttonForm"
import { InputForm } from "../inputForm"
import ModalLoading from "../modalLoading"
import Text from "../Text"
+import ToastCustom from "../toastCustom"
type Props = {
@@ -31,10 +33,9 @@ export default function ViewLogin({ onValidate }: Props) {
return onValidate({ phone: `62${phone}`, otp })
}
}
- return ToastAndroid.show(response.message, ToastAndroid.SHORT)
+ return Toast.show({ type: 'small', text1: response.message, })
} catch (error) {
- console.error('Error fetching data:', error);
- return ToastAndroid.show(`Terjadi kesalahan ${error}`, ToastAndroid.SHORT)
+ return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
} finally {
setLoadingLogin(false)
}
@@ -42,6 +43,7 @@ export default function ViewLogin({ onValidate }: Props) {
return (
+
+
Toast.hide()} visibilityTime={1500} position="bottom" config={{
+ small: ({ text1 }) => (
+
+ {text1}
+
+ )
+ }} />
+ )
+}
\ No newline at end of file
diff --git a/constants/Styles.ts b/constants/Styles.ts
index 37e93f4..54ca02a 100644
--- a/constants/Styles.ts
+++ b/constants/Styles.ts
@@ -550,6 +550,14 @@ const Styles = StyleSheet.create({
top: 18,
left: 20,
position: 'absolute'
+ },
+ toastContainer: {
+ backgroundColor: 'white',
+ borderRadius: 10,
+ padding: 10,
+ width: '90%',
+ borderWidth: 1,
+ borderColor: '#d6d8f6',
}
})
diff --git a/lib/useNotification.ts b/lib/useNotification.ts
index 53a58b0..07f0f4b 100644
--- a/lib/useNotification.ts
+++ b/lib/useNotification.ts
@@ -1,8 +1,7 @@
import { getApp, getApps, initializeApp } from '@react-native-firebase/app';
-import { getMessaging } from '@react-native-firebase/messaging';
+import messaging, { getMessaging } from '@react-native-firebase/messaging';
import { useEffect } from 'react';
-import { PermissionsAndroid } from 'react-native';
-import { pushToPage } from './pushToPage';
+import { PermissionsAndroid, Platform } from 'react-native';
// Your Firebase project configuration
const RNfirebaseConfig = {
@@ -21,6 +20,8 @@ const initializeFirebase = async () => {
const app = getApps().length ? getApp() : initializeApp(RNfirebaseConfig);
const mess = getMessaging(app);
+ await messaging().registerDeviceForRemoteMessages();
+
// Set auto initialization and background message handler
mess.setAutoInitEnabled(true);
mess.setBackgroundMessageHandler(async remoteMessage => {
@@ -36,15 +37,17 @@ const initializeFirebase = async () => {
export const requestPermission = async () => {
try {
- const cek = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS)
- if (!cek) {
- const granted = await PermissionsAndroid.request(
- PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS
- );
- if (granted === PermissionsAndroid.RESULTS.GRANTED) {
- return true
+ if (Platform.OS === 'android') {
+ const cek = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS)
+ if (!cek) {
+ const granted = await PermissionsAndroid.request(
+ PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS
+ );
+ if (granted === PermissionsAndroid.RESULTS.GRANTED) {
+ return true
+ }
+ return false
}
- return false
}
return true
} catch (err) {
@@ -54,8 +57,8 @@ export const requestPermission = async () => {
export const getToken = async () => {
try {
- const mess = await initializeFirebase();
- const token = await mess?.getToken();
+ await initializeFirebase();
+ const token = await messaging().getToken();
return token;
} catch (error) {
console.error("Error getting token:", error);
diff --git a/package.json b/package.json
index cbdcf45..2b68bed 100644
--- a/package.json
+++ b/package.json
@@ -82,6 +82,7 @@
"react-native-safe-area-context": "5.4.0",
"react-native-screens": "~4.11.1",
"react-native-svg": "15.11.2",
+ "react-native-toast-message": "^2.3.3",
"react-native-ui-datepicker": "^3.0.5",
"react-native-web": "^0.20.0",
"react-native-webview": "13.13.5",
diff --git a/providers/AuthProvider.tsx b/providers/AuthProvider.tsx
index 0b99d09..77aad39 100644
--- a/providers/AuthProvider.tsx
+++ b/providers/AuthProvider.tsx
@@ -4,6 +4,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import CryptoES from "crypto-es";
import { router } from "expo-router";
import { createContext, MutableRefObject, ReactNode, useCallback, useContext, useEffect, useRef, useState } from 'react';
+import { Platform } from 'react-native';
const AuthContext = createContext<{
signIn: (arg0: string) => void;
@@ -76,7 +77,9 @@ export default function AuthProvider({ children }: { children: ReactNode }): Rea
try {
const hasil = await decryptToken(String(tokenRef.current))
const token = await getToken()
- const response = await apiUnregisteredToken({ user: hasil, token: String(token) })
+ if (Platform.OS === 'android'){
+ const response = await apiUnregisteredToken({ user: hasil, token: String(token) })
+ }
} catch (error) {
console.error(error)
} finally {