fix push notification delivery on android
This commit is contained in:
@@ -7,21 +7,15 @@ import {
|
||||
onMessage,
|
||||
onNotificationOpenedApp,
|
||||
getInitialNotification,
|
||||
setBackgroundMessageHandler,
|
||||
} from '@react-native-firebase/messaging';
|
||||
import { registerDeviceToken, listenForTokenRefresh, displayLocalNotification } from '@/services/notifications';
|
||||
import { registerDeviceToken, listenForTokenRefresh } from '@/services/notifications';
|
||||
import { AuthProvider, useAuth } from "@/context/AuthContext";
|
||||
import { useUpdatecheck } from '@/hooks/useUpdatecheck';
|
||||
import { UpdatePrompt } from '@/components/UpdatePrompt';
|
||||
import Toast from 'react-native-toast-message';
|
||||
|
||||
// Registered at module scope so it's installed as soon as this entry file
|
||||
// loads, which is required for it to fire while the app is backgrounded/killed.
|
||||
setBackgroundMessageHandler(getMessaging(), async (remoteMessage) => {
|
||||
const title = remoteMessage.data?.title as string | undefined;
|
||||
const body = remoteMessage.data?.body as string | undefined;
|
||||
await displayLocalNotification(title, body);
|
||||
});
|
||||
// The FCM background handler now lives in index.js (registered before this
|
||||
// module loads) so it fires reliably while the app is backgrounded/killed.
|
||||
|
||||
function NotificationSetup() {
|
||||
const { user, loading } = useAuth();
|
||||
|
||||
Reference in New Issue
Block a user