upd: push notification ios

Deskripsi:
- push notification foreground dan background pada ios

No Issues
This commit is contained in:
2025-09-24 17:37:00 +08:00
parent 93c492ac71
commit f042e32d98
4 changed files with 116 additions and 111 deletions

View File

@@ -5,7 +5,6 @@ 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;
@@ -57,13 +56,13 @@ export default function AuthProvider({ children }: { children: ReactNode }): Rea
const permission = await requestPermission()
if (permission) {
try {
// COMING SOON
if (Platform.OS === 'android') {
const tokenDevice = await getToken()
const register = await apiRegisteredToken({ user: hasil, token: String(tokenDevice) })
}else{
const register = await apiRegisteredToken({ user: hasil, token: "" })
}
// if (Platform.OS === 'android') {
const tokenDevice = await getToken()
const register = await apiRegisteredToken({ user: hasil, token: String(tokenDevice) })
// }else{
// const tokenDevice = await getToken()
// const register = await apiRegisteredToken({ user: hasil, token: String(tokenDevice) })
// }
} catch (error) {
console.error(error)
} finally {
@@ -82,13 +81,12 @@ export default function AuthProvider({ children }: { children: ReactNode }): Rea
const signOut = useCallback(async () => {
try {
const hasil = await decryptToken(String(tokenRef.current))
// COMING SOON
if (Platform.OS === 'android') {
const token = await getToken()
const response = await apiUnregisteredToken({ user: hasil, token: String(token) })
}else{
const response = await apiUnregisteredToken({ user: hasil, token: "" })
}
// if (Platform.OS === 'android') {
const token = await getToken()
const response = await apiUnregisteredToken({ user: hasil, token: String(token) })
// }else{
// const response = await apiUnregisteredToken({ user: hasil, token: "" })
// }
} catch (error) {
console.error(error)
} finally {