Apple Push Notification Collapse Key Equivalent

前端 未结 5 1692
梦如初夏
梦如初夏 2021-02-05 05:41

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

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 06:37

    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.

提交回复
热议问题