This repository has been archived by the owner on Nov 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
43 lines (35 loc) · 1.71 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//Leave as a JS file
//https://reactnative.dev/docs/typescript#adding-typescript-to-an-existing-project
import { AppRegistry } from 'react-native';
import App from './App';
import React from 'react'
import { name as appName } from './app.json';
import 'react-native-gesture-handler' //For react-navigation
import messaging from '@react-native-firebase/messaging';
import { handleFCMMessage } from 'utils/fcmNotificationHandlers';
import codePush from "react-native-code-push";
import 'react-native-get-random-values' //https://github.com/uuidjs/uuid#getrandomvalues-not-supported
import PushNotification from "react-native-push-notification";
//We'll manage the updating and whatnot to ourselves since we want a really
//reliable and fast update delivery
//https://manurana.medium.com/codepush-update-strategies-for-a-react-native-app-6c0d2acd4f4c
//(keep in mind emulators connected to RN server will
//never be synched with codepush sicne we don't give them api keys)
let codePushOptions = {
checkFrequency: codePush.CheckFrequency.MANUAL
};
const CodePushApp = codePush(codePushOptions)(App)
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
await handleFCMMessage(remoteMessage)
});
//https://rnfirebase.io/messaging/usage#background-application-state
function HeadlessCheckedApp({ isHeadless }) {
// If app has been "launched" in the background by iOS due to FCM, ignore
if (isHeadless) return null;
return <CodePushApp />;
}
// Must be outside of any component LifeCycle (such as `componentDidMount`).
// Might not be needed since we're no longer using it in our fcm handlers
// but we'll keep it in anyways
PushNotification.configure({});
AppRegistry.registerComponent(appName, () => HeadlessCheckedApp);