Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple Push Notification Collapse Key Equivalent

When using Google push notifications, I am allowed to specify a collapse_key value so a device will not receive multiple notifications of the same collapse_key. Does APNS have a similar feature or does anyone know a way to emulate this functionality?

like image 555
David Avatar asked Sep 13 '12 19:09

David


People also ask

What is APNs collapse ID?

The APNs request header key for the collapse identifier is apns-collapse-id and is defined in Table 6-2. For example, a news service that sends the same headline twice in a row could employ the same collapse identifier for both push notification requests.

Do APNs sandbox?

A channel is a type of platform that you can deliver messages to. You can use the APNs sandbox channel to send push notification messages to the sandbox environment of the Apple Push Notification service (APNs).

How do I use Apple push notifications for APN?

Establish a Connection to APNs Use HTTP/2 and TLS 1.2 or later to establish a connection between your provider server and one of the following servers: Development server: api.sandbox.push.apple.com:443. Production server: api.push.apple.com:443.

Are Apple push notifications guaranteed?

The system makes every attempt to deliver local and remote notifications in a timely manner, but delivery isn't guaranteed. The PushKit framework offers a more timely delivery mechanism for specific types of notifications, such as those VoIP and watchOS complications use. For more information, see PushKit.


Video Answer


2 Answers

As of iOS 10 and using the HTTP/2.0 APNS API, you can specify apns-collapse-id header and handle the collapse logic in your app.

Collapsed notifications will appear as one single notification on the device that keeps updating with new data. Each time a notification is updated it is pushed to the top of your unread notifications.

Description of apns-collapse-id taken from https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html:

Multiple notifications with same collapse identifier are displayed to the user as a single notification. The value should not exceed 64 bytes. For more information, see Quality of Service, Store-and-Forward, and Coalesced Notifications.

and from https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW1:

When a device is online, all the notifications you send are delivered and available to the user. However, you can avoid showing duplicate notifications by employing a collapse identifier across multiple, identical notifications. The APNs request header key for the collapse identifier is apns-collapse-id and is defined in Table 6-2.

For example, a news service that sends the same headline twice in a row could employ the same collapse identifier for both push notification requests. APNs would then take care of coalescing these requests into a single notification for delivery to a device.

like image 172
Doody P Avatar answered Oct 13 '22 00:10

Doody P


With iOS 10 there is a new "apns-collapse-id" which looks like it will handle this sort of need. If you have an Apple developer account you can look at the WWDC 2016 notification session videos (707 intro video https://developer.apple.com/videos/play/wwdc2016/707/).

like image 33
chadbag Avatar answered Oct 13 '22 00:10

chadbag