expo: addNotificationResponseReceivedListener and useLastNotificationResponse not triggered for killed iOS apps SDK 40
🐛 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
class HandlePushNotifications extends Component {
componentDidMount() {
this.onResponseReceivedListener = Notifications.addNotificationResponseReceivedListener(
this.handlePush <-- This is never triggered when the app was killed on iOS.
);
}
}
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.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (9 by maintainers)
Commits related to this issue
- [expo-notifications] Register emitter as center delegate's delegate only once JS subscribes to it (#11382) # Why Fixes a bug introduced in https://github.com/expo/expo/pull/10883 which causes init... — committed to expo/expo by sjchmiela 4 years ago
- [expo-notifications] Do not consider pending notification response delivered unless they're delivered to expo-notifications (#11378) # Why It's a nice counterpart to https://github.com/expo/expo/p... — committed to expo/expo by sjchmiela 4 years ago
- [expo-notifications] Register emitter as center delegate's delegate only once JS subscribes to it (#11382) # Why Fixes a bug introduced in https://github.com/expo/expo/pull/10883 which causes init... — committed to expo/expo by sjchmiela 4 years ago
- [expo-notifications] Do not consider pending notification response delivered unless they're delivered to expo-notifications (#11378) # Why It's a nice counterpart to https://github.com/expo/expo/p... — committed to expo/expo by sjchmiela 4 years ago
If by any npm stuff on local dev you mean:
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
ExpoKitregistering its own legacy notification manager before aforementionedEXNotificationsEmitteris initialized which causes the legacy manager to consume all pending notification responses — they never get toexpo-notifications.We’ll fix this as soon as possible.
@sjchmiela For me the problem is that
useLastNotificationResponsedoes not trigger with the app killed on iOS. My impression is that on your example the app is backgrounded, which doesn’t present issue on my apps.@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.
Some changes in the following packages that may fix this issue have just been published to npm under
nexttag 🚀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! 🎉
Yeahhhhh… It works!!! Both, Android and iOS. You made my day!
Copying https://github.com/expo/expo/issues/9866#issuecomment-747520380:
This being said, let us know if this or similar problem ever rises again! 😃
Copying from https://github.com/expo/expo/issues/9866#issuecomment-747101532: