Files
etf-oglasi/frontend/index.js
T
ksan 45e57181a9
CI/CD / Backend Unit Tests (push) Successful in 2m16s
CI/CD / Deploy (push) Successful in 2m6s
CI/CD / Mobile Release (push) Successful in 22m0s
fix push notification delivery on android
2026-07-30 15:28:12 +02:00

28 lines
1.0 KiB
JavaScript

// Custom entry point. The FCM background handler must be registered in the very
// first module that loads — before the router/app mounts — so it reliably fires
// when the app is backgrounded or fully quit. Registering it here (rather than in
// app/_layout.tsx) is what react-native-firebase requires for the killed state.
import messaging from '@react-native-firebase/messaging';
import notifee, { AndroidImportance } from '@notifee/react-native';
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
const title = remoteMessage.data?.title;
const body = remoteMessage.data?.body;
if (!title && !body) return;
const channelId = await notifee.createChannel({
id: 'default',
name: 'General',
importance: AndroidImportance.HIGH,
});
await notifee.displayNotification({
title,
body,
android: { channelId, pressAction: { id: 'default' } },
});
});
// Hand off to expo-router, which mounts app/_layout.tsx and the routes.
import 'expo-router/entry';