Apple Push Notification Collapse Key Equivalent
Doody P's answer works for remote notifications, but there is also an equivalent for locally triggered notifications: when you create your UNNotificationRequest, you can set the identifier
parameter to whatever you had been using as a collapse key. After being triggered, the push notification will show only the latest version that you sent with that identifier.
(We send push notifications silently through APNs and then retrigger as local notifications, because we need to make sure that our users are logged in.)
There are handy code examples & demos of managing delivered notifications in this WWDC talk - the key section is from ~18:00 - 21:00.
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/).
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.