开发者社区> 问答> 正文

当从后台移除并尝试打开时,反应本机iOS应用程序崩溃

我已经创建了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

展开
收起
游客5akardh5cojhg 2019-12-14 18:09:18 410 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载