I’m encountering an issue with push notifications in my Capacitor iOS app. The notifications work correctly when registering, but when I try to clear notifications by calling: PushNotifications.removeAllDeliveredNotifications(); , it is returning the error:
[error] - {“errorMessage”:“event capacitorDidRegisterForRemoteNotifications not called. Visit Push Notifications Capacitor Plugin API | Capacitor Documentation for more information”,“message”:“event capacitorDidRegisterForRemoteNotifications not called. Visit Push Notifications Capacitor Plugin API | Capacitor Documentation for more information”}
In my swift delegate, I have this code, which works perfectly fine when registering and receiving notifications, but doesn’t get called when clearing for some reason:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
Messaging.messaging().token(completion: { (token, error) in
if let error = error {
NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
} else if let token = token {
NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: token)
}
})
}
All the notifications are building up in the notification center and the app badge is not being removed.
Any insights or suggestions would be greatly appreciated. Thank you!
1 post - 1 participant