Managing pending and delivered notifications

When you learned about scheduling notifications, you saw that each notification is assigned a unique identifier. If a new notification is added with an identifier that has already been used, the new notification will overwrite the existing notification, limiting the amount of similar and duplicate notifications in the Notification Center.

This overwrite behavior applies to both delivered and pending notifications. This means that you can replace a notification that the user has already received by scheduling a second notification with the same identifier. This is especially useful if the new notification makes the old notification obsolete. For instance, consider a situation when you send push messages to update a user about the current score for a sports match. If you push each score update with the same identifier, the user will always see a single notification with the most recent score.

You can also remove delivered notifications by calling removeDeliveredNotifications(withIdentifiers:) on the notification center in your app. If your app allows the user to select the types of notification they want to receive, you could use this feature to remove all notifications of a certain type. That way, the user won't see the notifications anymore.

To update notifications that have been sent by your server, you push a new notification with the apns-collapse-id header set on the request that your server sends to APNS. If this header is present, the new notification will overwrite any existing notifications that have been pushed with the same apns-collapse-id.

Updating your notifications, instead of pushing new ones all the time, is a great way to avoid needless clutter in the Notification Center. More importantly, there won't be any duplicate, redundant, or outdated messages fighting for the user's attention.

Let's see how you can further improve the notification experience through custom actions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.153.38