-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (37 loc) · 1.25 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
43
44
45
46
47
48
/**
* @format
*/
import { AppRegistry, LogBox, Linking } from 'react-native';
import messaging from '@react-native-firebase/messaging';
import { showMessage } from 'react-native-flash-message';
import { name as appName } from './app.json';
import App from './src';
import './src/Functions/OpenAppTimes';
import Sentry from './src/Services/Sentry';
LogBox.ignoreLogs(['EventEmitter.removeListener', 'new NativeEventEmitter()']);
// Register background handler
messaging().setBackgroundMessageHandler(async remoteMessage => {
console.log(
'Message handled in the background!',
JSON.stringify(remoteMessage)
);
});
messaging().onNotificationOpenedApp(async remoteMessage => {
if (remoteMessage.data.deeplinking) {
await Linking.openURL(remoteMessage.data.deeplinking);
}
});
messaging().onMessage(async remoteMessage => {
async function onOpen() {
if (remoteMessage.data.deeplinking) {
await Linking.openURL(remoteMessage.data.deeplinking);
}
}
showMessage({
message: remoteMessage.notification.title,
description: remoteMessage.notification.body,
onPress: onOpen,
});
});
const sentry = Sentry.wrap(App);
AppRegistry.registerComponent(appName, () => sentry);