Apple 推送通知折叠键等效项 [英] Apple Push Notification Collapse Key Equivalent
问题描述
当使用 Google 推送通知时,我可以指定一个 collapse_key 值,这样设备就不会收到同一个 collapse_key 的多个通知.APNS 有没有类似的功能,或者有人知道模拟这个功能的方法吗?
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?
推荐答案
从 iOS 10 开始,使用 HTTP/2.0 APNS API,您可以指定 apns-collapse-id
标头并处理折叠应用中的逻辑.
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.
apns-collapse-id
的描述取自 https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html:
显示多个具有相同折叠标识符的通知用户作为单个通知.该值不应超过 64字节.有关更多信息,请参阅服务质量,存储转发和合并通知.
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.
当设备在线时,您发送的所有通知都会发送并可供用户使用.但是,您可以避免显示重复通过跨多个使用折叠标识符来通知,相同的通知.用于折叠的 APNs 请求标头密钥标识符为apns-collapse-id,定义见表6-2.
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.
例如,一个新闻服务在同一时间两次发送相同的标题行可以为两个推送使用相同的折叠标识符通知请求.然后 APN 将负责合并这些请求转换为单个通知以传送到设备.
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.
这篇关于Apple 推送通知折叠键等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!