[unimodules][android][notifications] Event listener can miss `emit()` calls made soon after app launch
See original GitHub issueš Bug Report
Summary of Issue
If you call Notifications.addResponseReceivedListener
in useEffect
for example, the listener will not be triggered when opening an app from a completely killed state via a notification. This can also be demonstrated by adding a timeout to componentDidMount
as shown here. Without 1 second timeout- events come through; with 1 second timeout- eventās do not come through.
I should note that the emit method is getting called in this case.
Environment - output of expo diagnostics
& the platform(s) youāre targeting
Reproducible Demo
https://snack.expo.io/@charliecruzan/push-notifications
Steps to Reproduce
Need to run the app as a published experience or standalone app (or bare debug build) to see the behavior. Press āshow notificationā and kill the app, tap the notification, observe that response listener isnāt triggered.
Workaround
The workaround (and possibly long-term solution) is to add the listener outside of any component, then it works as expected (presumably bc of how much sooner itās getting called?). I changed the docs to suggest this so fewer people run into this issue
Issue Analytics
- State:
- Created 3 years ago
- Comments:101 (24 by maintainers)
Hi @cruzach, Works when app is in background, but not when the app is killed. The issue still persist on Android with both SDK 38 and SDK 39 in a managed workflow. I try to move out
addNotificationResponseReceivedListener
outside of my component as suggested, but it doesnāt work.Thanks
It doesnāt work either on background and killed. The response will be nullā¦