I have created React native iOS application. Everything is working fine in my application I have handle push notification also. For this I used this code. It manage my application foreground , background both states. But when I remove my application from the background and try to open it. It is crashing after splash screen. Even I remove this push notification code but still I am not able to open my application it is crashing always.
async createNotificationListenersIos() {
console.log("createNotificationListenersIOs ");
/* Triggered when a particular notification has been received in foreground */
const channel = new firebase.notifications.Android.Channel('test-channel', 'Test Channel', firebase.notifications.Android.Importance.Max)
.setDescription('My apps test channel');
// Create the channel
firebase.notifications().android.createChannel(channel);
this.notificationListener = firebase.notifications().onNotification((notification) => {
console.log(" notification is === 81 ", notification);
notification
.android.setChannelId('test-channel')
.android.setSmallIcon('ic_launcher');
firebase.notifications()
.displayNotification(notification);
this.checkForData(notification);
});
/*
* If your app is in background, you can listen for when a notification is clicked / tapped / opened as follows: */
this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
console.log(" notification is === 99 =======", notificationOpen.notification);
this.checkForData(notificationOpen.notification);
});
/*
* If your app is closed, you can check if it was opened by a notification being clicked / tapped / opened as follows:
*/
/*
firebase.notifications().getInitialNotification()
.then((notificationOpen: NotificationOpen) => {
if (notificationOpen) {
console.log(" 45 ===== ", notificationOpen);
// App was opened by a notification
// Get the action triggered by the notification being opened
const action = notificationOpen.action;
// Get information about the notification that was opened
const notification: Notification = notificationOpen.notification;
if (notification) {
// console.log("+================= notificationOpen ", notification, "===========");
// App was opened by a notification
// Get the action triggered by the notification being opened
// const action = notificationOpen.action;
// Get information about the notification that was opened
console.log("^^^^^^^^^^^^^^^^^^",notification._notification);
this.checkForData(notification._notification)
}
}
});
*/
}
checkForData (notification){
if (notification._data) {
if(notification._data.type){
if ( notification._data.type.toUpperCase() !== wordConstants.CONST_ADMIN) {
return;
}
}
console.log("69 ^^^^^^^^^^^^^^^^^^",notification._data.status);
let notificationStatus = notification._data.status;
console.log(" notification status ====", notificationStatus.toUpperCase());
if(notificationStatus.toUpperCase() === wordConstants.CONST_APPROVE){
this.props.navigation.navigate('LoginProgress', { status: wordConstants.CONST_CONFIRM, userData: {} });
}else{
this.props.navigation.navigate('LoginProgress', { status: wordConstants.CONST_FAILED, userData: {} });
}
} else {
}
}
Can anyone help me.
Thanks