Multiple push notification service

my app using FCM and pushy to deliver notif at the same time, the situation that is happening now is that I am getting two similar notification banners. How do I delete/cancel one of the notification banners when one of them has appeared.

How do I handle this on the frontend side? If it is not possible/not recommended, can you please provide documentation from Apple so that it is best to change it on the server side

Answered by Engineer in 764277022

While your use case using multiple services seems a bit out of the ordinary, if you want to merge multiple notifications into a single one for the user, you would want to be using the HTTP/2 header "apns-collapse-id". Back to back notifications with the same collapse id will be merged and only one will be shown to the user. Not knowing exactly what the multiple notification conditions, timing, etc. are, you may hit some edge cases where the notifications may not be merged. Documented here: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns

To be able to process incoming notifications on the app side, you would need to create a Notification Service Extension (https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension) where you can change the contents of the notification, but cannot easily delete/cancel it on the fly. For that, you will need to use a special entitlement, which you can request, but may or may not receive depending on your use case (https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_usernotifications_filtering)

But even without the entitlement, you would be able to change the contents in a way to avoid confusing the user with two identical notifications.

Accepted Answer

While your use case using multiple services seems a bit out of the ordinary, if you want to merge multiple notifications into a single one for the user, you would want to be using the HTTP/2 header "apns-collapse-id". Back to back notifications with the same collapse id will be merged and only one will be shown to the user. Not knowing exactly what the multiple notification conditions, timing, etc. are, you may hit some edge cases where the notifications may not be merged. Documented here: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns

To be able to process incoming notifications on the app side, you would need to create a Notification Service Extension (https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension) where you can change the contents of the notification, but cannot easily delete/cancel it on the fly. For that, you will need to use a special entitlement, which you can request, but may or may not receive depending on your use case (https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_usernotifications_filtering)

But even without the entitlement, you would be able to change the contents in a way to avoid confusing the user with two identical notifications.

Thank you for your help, it's true that it's very strange to use two notification services at once, and I've tried using the HTTP/2 header "apns-collapse-id" this works and combines the notifications into 1 when the iPhone is locked, while when the iPhone is open (unlocked) the notification banner still two. and I didn't find any solution for this except sending the exact same notification only 1 time.

Additionally, why use two notification services ? is as a backup, if the first one is not received by the user, then the user can receive the second one and vice versa

Multiple push notification service
 
 
Q