Post

Replies

Boosts

Views

Activity

Remotely dismissing notifications on iOS
I am sending push notifications on iOS, and I can receive and display them correctly. I want to be able to dismiss notifications that have been read server-side (e.g. on a different device) so I am trying to send a custom notification payload alongside a badge counter update, that specifies what notification IDs to remove. I then use removeDeliveredNotifications on the IDs I get. However, it doesn't seem to be working. I am setting the identifier using the apns-collapse-id header and I do see that reflected on the device side. Any ideas what I might be doing wrong? This is how I'm handling push notifications: func userNotificationCenter( _ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void ) { let customPayload = notification.request.content.userInfo if let dismissedNotifications = customPayload["dismissed_notifications"] as? [String] { center.removeDeliveredNotifications(withIdentifiers: dismissedNotifications) } completionHandler([.banner, .sound, .badge]) } I also tried doing the same thing inside func userNotificationCenter( _ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void ) Thank you!
3
0
256
1w