我已经创建了Reaction本机IOS应用程序。在我的应用程序中,一切都很好,我也处理了推送通知。为此,我使用了以下代码。它管理我的应用前景,后台两种状态。但是当我从后台删除我的应用程序并尝试打开它时。它在飞溅屏幕后崩溃了。即使我删除了这个推送通知代码,但我仍然无法打开我的应用程序,它总是崩溃。
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
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。