Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
notification.finish(PushNotificationIOS.FetchResult.NoData)
}
},
// Android only
senderID: '162663374736',
// iOS only
permissions: DEFAULT_NOTIFICATION_PERMISSIONS,
// Should the initial notification be popped automatically
popInitialNotification: true,
requestPermissions: Platform.OS !== 'ios'
})
if (Platform.os === 'ios') {
// Get notifications that triggered an open of the app when the app was
// completely closed
PushNotificationIOS.getInitialNotification().then(notification => {
if (notification) {
// backgroundNotification is an instance of PushNotificationIOS, create
// a notification object from it
const notificationObj = {
alert: this.state.backgroundNotification.getAlert(),
data: this.state.backgroundNotification.getData()
}
// Pop the alert with option to redirect to WebView
this.onNotification(notificationObj)
}
})
// Get notifications that were triggered when the app was backgrounded
PushNotificationIOS.addEventListener('notification', notification => {
if (AppState.currentState === 'background') {
// Save notification to state so it can be dealt with when the user
_checkIfOpenedByCampaign(nextAppState) {
// the app is turned from background to foreground
if (
this._currentState.match(/inactive|background/) &&
nextAppState === 'active'
) {
PushNotificationIOS.getInitialNotification()
.then(data => {
if (data) {
this.handleCampaignOpened(data);
}
})
.catch(e => {
logger.debug('Failed to get the initial notification.', e);
});
}
this._currentState = nextAppState;
}