当应用程序处于后台时,点击通知横幅时,应用程序崩溃

时间:2020-09-08 15:11:04

标签: ios react-native push-notification react-native-push-notification

每当我的应用程序处于“退出”或“背景”状态时,我都会点击iPhone中收到的通知。方法didReceiveNotificationResponse中的应用程序崩溃,发生以下错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIWindow userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:]: unrecognized selector sent to instance 0x11be51e40'

是否由于仅 handle the selection of Custom Actions 这种方法而发生? ?因为我的通知只是纯通知,没有任何操作按钮。用户只能点击它以启动应用程序。

enter image description here 在第94行崩溃。如果我注释掉整个方法didReceiveNotificationResponse,它将执行第96行而不会崩溃。

我的目标是确定应用程序是在QUIT还是BACKGROUND状态下启动的。然后,我将相应地处理Deeplink。我可能可以用...来检查这个……

PushNotificationIOS.getInitialNotification();-退出状态

PushNotificationIOS.addEventListener('notification', (notification) =>)-背景状态


更新

  1. 为我自己找到了一个临时解决方案。将最新代码(仅是受影响的方法)恢复为先前的代码,因为这是唯一会导致错误的部分。现在,我的项目按预期方式构建并运行。但是,这不是解决方案。

0 个答案:

没有答案