Closed mrkelvinli closed 3 years ago
We seems to have re-implement the push notification plugin in Capacitor 3.0 (in NotificationRouter.swift
). Not sure if this is still an issue in version 3?
I can't reproduce on Capacitor 3, so might be fixed. If you upgrade to Capacitor 3 and still face the issue, please, report it on https://github.com/ionic-team/capacitor-plugins/issues
For those who have used the cordova-plugin-local-notification and @ionic-native/local-notifications, you may encounter this same problem in Capacitor3; please remove all references to these plugins, completely "npm remove" the packages and change to use @capacitor/local-notifications instead
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
Bug Report
Capacitor Version
Platform(s)
iOS
Current Behavior
Not receiving
pushNotificationReceived
event when the iOS app is in foreground. However, I gotpushNotificationReceived
events on Android when there is a new incoming push notification.I am having this issue on my iPhone 12 with iOS 14.4.1
Expected Behavior
Receive a
pushNotificationReceived
event whenever the app receives a push notification.Code Reproduction
Other Technical Details
npm --version
output:6.14.10
node --version
output:v14.15.4
pod --version
output (iOS issues only):1.10.1
There is a similar issue #4145 but it is for when the app is in background.
Additional Context
I looked into the PushNotifications plugin implementation in Swift and realised that if we reset the
UserNotificationCenter.delegate
after the permission was granted, then every started working again. I couldn't justify why this works, but it works. Any thoughts?Reference: https://www.raywenderlich.com/books/push-notifications-by-tutorials/v2.0/chapters/8-handling-common-scenarios
node_modules/@capacitor/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift