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
addNotificationResponseReceivedListener and useLastNotificationResponse not triggered for killed iOS apps SDK 40 #11343
Comments
Thanks for the bug report! We can look into this. I confirmed the behavior As a workaround, can you try using the |
I just tried it, but it doesn't trigger with the app killed. So, I would love to see |
I am observing this even with a backgrounded app on iOS, so the app doesn't even need to be killed. This basically renders my app useless :( (only tested with one device - in the past, my mileage with push notification varied quite a bit across devices, unfortunately) |
@hardcodet that's not the behavior I've seen so I suggest you double-check your JS code, and test a minimal example like the one from the docs https://docs.expo.io/versions/latest/sdk/notifications/ |
Indeed, SDK40 introduced a change to behavior of notifications emitter on iOS which sounds like it could cause what you're describing. So:
All in all what I wanted to say is:
I just wrote this snack that shows how one could use/verify if |
@cruzach As said, my mileage does vary. My push notification code hasn't changed in months, and some devices seem to work, others not, and some used to work and no longer do (or no longer do for now). An sometimes, those notifications just come in 10-20 mins too late (as observed yesterday on my Android phone). Been like that for a while though. I'm not convinced this part of expo is production-ready TBH. |
@sjchmiela For me the problem is that |
I have the same problem as @maurohmartinez, it works on iOS when the application is in the background but not when it is kill |
Hey guys, I just reproduced it, I'll take a look into what we can do to fix this. As a workaround I can only suggest ejecting to bare workflow where this bug does not exist as far as I know. EDIT: the problem is most probably caused by We'll fix this as soon as possible. |
Actually, since it's If the app is being started as a result of tapping on a notification and Doing it like this:
I got: I think the actual proper fix shouldn't take too long to land (I would expect it to be available before the end of this week), but that's some workaround you could use if you need. |
I am waiting this fix. I am using hook |
…nly once JS subscribes to it (#11382) # Why Fixes a bug introduced in #10883 which causes initial notification responses to get lost in standalone iOS apps. Along with #11378 I believe it fixes #11343 and may also finally fix #9866. # How Using native breakpoints I've noticed `EXNotificationCenterDelegate`'s `addDelegate:` is called more times than I would expect it to. It turned out before `EXScopedNotificationsEmitter` was subscribing to `EXNotificationCenterDelegate` (it would then receive pending notification response) an unscoped `EXNotificationsEmitter` was subscribing and consuming pending responses. Since unscoped emitter wasn't being used and exposed to the app later, it consumed the response into the void. Most probably unimodules have a bug where instances of overridden modules are still kept in memory (since `setModuleRegistry:` is called on them). Fixing this bug is out of the scope of this pull request. These changes are based on how it was implemented before dfda625. I can't see any reason why `EXNotificationsEmitter` would need to register for notifications as soon as module registry is ready, so let's roll back to what we know worked well. # Test Plan I have verified in an ExpoKit workspace that when the app is opened from a notification, the notification response is delivered to `useLastNotificationResponse`: https://www.loom.com/share/586a906c538f47f0940b2cc83582fb29
…livered unless they're delivered to expo-notifications (#11378) # Why It's a nice counterpart to #11382 which ensures #11343 and #9866 do not happen again. # How Follow-up to #9478. There are two places where the notification response can be "consumed" — when it is received (covered by #9478) and when it is delivered to a new delegate (covered by this PR). # Test Plan I have verified in #11382 that workspace with this and #11382 changes delivers initial notification response to the app.
…nly once JS subscribes to it (#11382) # Why Fixes a bug introduced in #10883 which causes initial notification responses to get lost in standalone iOS apps. Along with #11378 I believe it fixes #11343 and may also finally fix #9866. # How Using native breakpoints I've noticed `EXNotificationCenterDelegate`'s `addDelegate:` is called more times than I would expect it to. It turned out before `EXScopedNotificationsEmitter` was subscribing to `EXNotificationCenterDelegate` (it would then receive pending notification response) an unscoped `EXNotificationsEmitter` was subscribing and consuming pending responses. Since unscoped emitter wasn't being used and exposed to the app later, it consumed the response into the void. Most probably unimodules have a bug where instances of overridden modules are still kept in memory (since `setModuleRegistry:` is called on them). Fixing this bug is out of the scope of this pull request. These changes are based on how it was implemented before dfda625. I can't see any reason why `EXNotificationsEmitter` would need to register for notifications as soon as module registry is ready, so let's roll back to what we know worked well. # Test Plan I have verified in an ExpoKit workspace that when the app is opened from a notification, the notification response is delivered to `useLastNotificationResponse`: https://www.loom.com/share/586a906c538f47f0940b2cc83582fb29
…livered unless they're delivered to expo-notifications (#11378) # Why It's a nice counterpart to #11382 which ensures #11343 and #9866 do not happen again. # How Follow-up to #9478. There are two places where the notification response can be "consumed" — when it is received (covered by #9478) and when it is delivered to a new delegate (covered by this PR). # Test Plan I have verified in #11382 that workspace with this and #11382 changes delivers initial notification response to the app.
Copying from #9866 (comment):
|
Copying #9866 (comment):
This being said, let us know if this or similar problem ever rises again! 😃 |
Yeahhhhh... It works!!!! Both, Android and iOS. You made my day! |
@sjchmiela, Good job! need any npm stuff on local dev? |
If by any npm stuff on local dev you mean:
|
Same issue. How can i do it in class component? |
Some changes in the following packages that may fix this issue have just been published to npm under
If you're using bare workflow you can upgrade them right away. We kindly ask you for some feedback—even if it works 🙏 They will become available in managed workflow with the next SDK release 👀 Happy Coding! 🎉 |
🐛 Bug Report
After updating to SDK 40 expo-notifications does not trigger addNotificationResponseReceivedListener after app was killed on iOS. This last upgrade did fix the issue on Android, but now I am having that same problem on iOS.
SDK 40
Standalone App (I built a new bundle after updating to SDK 40)
Only on iOS.
Expo CLI 4.0.13 environment info:
System:
OS: macOS 11.0.1
Shell: 5.8 - /bin/zsh
Binaries:
Node: 12.18.4 - /usr/local/bin/node
npm: 6.14.9 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 14.2, DriverKit 20.0, macOS 11.0, tvOS 14.2, watchOS 7.1
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.6953283
Xcode: 12.2/12B45b - /usr/bin/xcodebuild
npmPackages:
expo: ^40.0.0 => 40.0.0
react: 16.13.1 => 16.13.1
react-dom: 16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-40.0.0.tar.gz => 0.63.2
react-native-web: ~0.13.12 => 0.13.18
npmGlobalPackages:
expo-cli: 4.0.13
Expo Workflow: managed
Reproducible Demo
Steps to Reproduce
Kill the app, Send a push notification, tap on that push (it opens the app)
Expected Behavior vs Actual Behavior
Expected Behavior: Notifications.addNotificationResponseReceivedListener triggers since the user interacted with the push.
Actual Behavior: The triggering of Notifications.addNotificationResponseReceivedListener never occurs.
The text was updated successfully, but these errors were encountered: