fixed push notifications and auth modified
CI/CD / Backend Unit Tests (push) Successful in 2m17s
CI/CD / Deploy (push) Successful in 2m26s

This commit is contained in:
2026-06-11 13:30:36 +02:00
parent 3afe5e2931
commit 7d7e641f5b
8 changed files with 72 additions and 9 deletions
+12 -2
View File
@@ -7,11 +7,20 @@ import {
onMessage,
onNotificationOpenedApp,
getInitialNotification,
setBackgroundMessageHandler,
} from '@react-native-firebase/messaging';
import { registerDeviceToken, listenForTokenRefresh } from '@/services/notifications';
import { registerDeviceToken, listenForTokenRefresh, displayLocalNotification } from '@/services/notifications';
import { AuthProvider, useAuth } from "@/context/AuthContext";
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);
});
function NotificationSetup() {
const { user, loading } = useAuth();
@@ -27,7 +36,8 @@ function NotificationSetup() {
console.log('Foreground notification:', msg);
Toast.show({
type: 'info',
text1: msg.notification?.title ?? 'New Notification',
text1: (msg.data?.title as string | undefined) ?? 'New Notification',
text2: msg.data?.body as string | undefined,
position: 'top',
visibilityTime: 4000,
});