react-native-fcm icon indicating copy to clipboard operation
react-native-fcm copied to clipboard

IOS - Crash when push notification is clicked on app killed state

Open shemilhashan opened this issue 7 years ago • 11 comments

RN Version 0.50.4 Device Iphone 7 plus 11.2 foreground,background works fine. I receive the push notifications, I click on them it goes to app fine.

But if we terminate the app -> send push -> click push -> app crashes

I have used it in the exact same way as you have done in the example.

Anyone has a solution?

shemilhashan avatar Jan 21 '18 06:01 shemilhashan

But if we terminate the app -> send push -> click push -> app crashes

if you terminate app, the app won't trigger any callback when you receive notification. Therefore your app should open to default landing page. However the logic related to initialNotification is triggered because you launch the app though notification. Remove the logic there and see if it keeps crashing

evollu avatar Jan 21 '18 16:01 evollu

I am facing the same the issue in app kill state. When I click on the notification my app crashes. I tried removing the logic inside initialNotification listener, but the behavior is still same.

nirajmchauhan avatar Mar 18 '18 11:03 nirajmchauhan

@nirajmchauhan try reproduce with example application. or provide a repo that i can access to reproduce

evollu avatar Mar 20 '18 15:03 evollu

Hi @evollu I'm facing the same issue. Everything works fine in android. Even in ios foreground and minimized state notification works fine but when the app is killed and you try to click the notification then app tries to open but crashes. I'm using non-cocoapod approach.

rameshbansal avatar Mar 23 '18 13:03 rameshbansal

@rameshbansal there must be some crash log. also try to reproduce with the example project in this repo. or provide a repo so I can reproduce it

evollu avatar Mar 23 '18 18:03 evollu

Hi @evollu my issue is resolved. I found out if you have connected a remote debugger and then you try to open app by clicking the notification when app is killed then it crashes the app otherwise after disabling remote debugger everything is working fine. Thanks

rameshbansal avatar Mar 26 '18 14:03 rameshbansal

@evollu i have a simple chat app, upon receiving a push notification when user taps on the notification, app opens and initialNotification is triggered, from there i navigate the user to specific chat to which the notification belongs, so far so good but the problem it that it is keep on navigating to the chat window again again, and eventually i have to kill the app.

There should be some option to remove initial notification once executed. i have tried following things but nothing is working.

        FCM.removeAllDeliveredNotifications();
           FCM.removeDeliveredNotification(notif["gcm.message_id"]);
           this.openThreadNow(notif, navigate);

please reply back ASAP.

husnaingoldev avatar May 17 '18 11:05 husnaingoldev

@husnaingoldev how about add a flag saying "initNotifHandled"?

evollu avatar May 21 '18 16:05 evollu

I can confirm that @rameshbansal comment works: RN Version 0.54.4 Device iPhone 7, iOS 11.4

andreipfeiffer avatar Jun 12 '18 10:06 andreipfeiffer

Hi I don't understand Ramesh comment about disabling the remote debugger? When I open remote push notifications when the app is in killed (by the user) state, the app opens but is immediately killed. What is the solution?

meidell avatar Apr 03 '19 13:04 meidell

The same issue. Open notification from app killed. CRASH. Fatal Exception: NSInternalInconsistencyException Error when sending event: FCMNotificationReceived with body: { "_actionIdentifier" = "com.apple.UNNotificationDefaultActionIdentifier"; "_completionHandlerId" = "828BEA51-76E7-4C53-8965-157091B1EA84"; "_notificationType" = "notification_response"; aps = { alert = { body = "tuan12313: nKey.thread.id]11111112"; title = "Visitor Message"; }; category = "SHOW_VISITOR_MESSAGES_ACTION"; }; "gcm.message_id" ="0:1556217872148442%db740235db740235"; "google.c.a.e" = 1; "opened_from_tray" = 1; }. Bridge is not set. This is probably because you've explicitly synthesized the bridge in RNFIRMessaging, even though it's inherited from RCTEventEmitter.

tuannguyenhoangit avatar Apr 26 '19 10:04 tuannguyenhoangit