33 lines
925 B
JavaScript
33 lines
925 B
JavaScript
import { registerRootComponent } from "expo";
|
|
import messaging from "@react-native-firebase/messaging";
|
|
import notifee from "@notifee/react-native";
|
|
|
|
import App from "./App";
|
|
|
|
import {
|
|
displayNotification,
|
|
triggerEvent,
|
|
} from "./src/providers/NotificationProvider";
|
|
|
|
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
|
|
// It also ensures that whether you load the app in Expo Go or in a native build,
|
|
// the environment is set up appropriately
|
|
|
|
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
|
|
console.log("Message handled in the background!", remoteMessage);
|
|
await displayNotification(remoteMessage.data);
|
|
});
|
|
|
|
notifee.onBackgroundEvent(triggerEvent);
|
|
|
|
function HeadlessCheck({ isHeadless }) {
|
|
if (isHeadless) {
|
|
// App has been launched in the background by iOS, ignore
|
|
return null;
|
|
}
|
|
|
|
return <App />;
|
|
}
|
|
|
|
registerRootComponent(App, () => HeadlessCheck);
|