-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (26 loc) · 1 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
/**
* @format
*/
import { AppRegistry } from "react-native"
import App from "./App"
import messaging from "@react-native-firebase/messaging"
import { name as appName } from "./app.json"
// Register background handler
// It must not attempt to updaet any UI (via state)
// you can however perform network requests, update local storage.
// remoteMessage contains all the custom data via the data property.
// if remoteMessage payload conatins a notification property, the device will have displayed a
// notification to the user.
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
console.log("Message handled in the background!", remoteMessage)
})
// Check if app was launched in the background and conditionally render null if so
function HeadlessCheck({ isHeadless }) {
if (isHeadless) {
// App has been launched in the background by iOS, ignore
return null
}
// Render the app component on foregound launch.
return <App />
}
AppRegistry.registerComponent(appName, () => HeadlessCheck)