-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
localNotification handler does not complete when woken from background #297
Comments
Not very nice, but without changing the lib, you can use this little 'hack' to make it work: https://gist.github.com/braandl/306640e2aa98392df5b654b2b35facad best |
Thanks @braandl, really appreciate the help! It looks promising debugging in the simulator, but only seems to work on the second try because the first time it wakes up it's loading a new bundle from Metro. Facing some other issues with release build, will report back once I'm able to test it out on release. At the very least the initial notifications come through on cold start now thanks to your code 💯 |
On a real device, this works for me also after re-bundling the app. From what I saw in the debugger, the native modules get invoked just normally and then the JS execution is paused until bundling is complete. Therefore I can then fetch the registered notification. But I never tested in any simulator. |
@braandl @edwinckc I have tried the above gist and the app crashes with a log"libc++abi.dylib: terminating with uncaught exception of type NSException". I am no a native guy it will be great if you can help me out with this. Appdelegate.m: https://gist.github.com/anishtr4/1d9c6aea15190aeb8a7f852f5c747be8 **Error log:**https://gist.github.com/anishtr4/8c87afbaff8ea7f5c5f917eb3af99a7d |
I am sorry, I do not have cloud messaging in my App, so I can only speak for local notifications. But according to Apples documentation (https://developer.apple.com/documentation/usernotificationsui/unnotificationcontentextension/1845197-didreceivenotificationresponse) it will work for all of them. |
When a notification is received,
didReceiveRemoteNotification
is called with a completion handler, which is then passed to RN. However, if the user performs an action on the notification, that is handled bydidReceiveNotificationResponse
, which does not have a completion handler.The RN listener for
localNotification
ends up being called, but the device does not wait for it to complete. This is okay when the app is in the foreground. If the app is in the background, the app gets woken up and the RN listener is started, but the RN handler does not complete before app goes to sleep again.The text was updated successfully, but these errors were encountered: