-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
30 lines (25 loc) · 1004 Bytes
/
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
/**
* @format
*/
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import PushNotificationIOS from '@react-native-community/push-notification-ios';
import PushNotification from 'react-native-push-notification';
import {Linking} from 'react-native';
// Must be outside of any component LifeCycle (such as `componentDidMount`).
PushNotification.configure({
// (required) Called when a remote is received or opened, or local notification is opened
onNotification: function (notification) {
// process the notification'
const {link = null} = notification?.data || {}; // <---- 1
if (link) {
Linking.openURL(link);
} else {
Linking.openURL('letterstoapp://notifications');
} // <---- 2
// (required) Called when a remote is received or opened, or local notification is opened
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
});
AppRegistry.registerComponent(appName, () => App);