apns-collapse-id不合并多个通知iOS 10 [英] apns-collapse-id not merging multiple notifications iOS 10
问题描述
我正在尝试在我的应用中折叠/合并属于同一事件的多个通知. iOS 10在有效负载中引入了键名apns-collapse-id.文档说,多个具有相同apns-collapse-id
的远程通知将合并并显示为单个通知.
I am trying to collapse/merge multiple notifications belonging to same event in my app. iOS 10 introduced a key name apns-collapse-id in payload. Document says multiple remote notifications with same apns-collapse-id
will merged and shown as single notification.
因此,我们的通知有效负载中包含具有apns-collapse-id
和thread-id
的有效负载.不幸的是,由于在线上没有太多内容解释这些键的实际工作方式,为了安全起见,我们为apns-collapse-id
和thread-id
使用了相同的唯一值.
So we have the payload with apns-collapse-id
and thread-id
in our notification payload. Unfortunately as there is no much content online explaining how these keys actually works, for safe play we have used the same unique value for both apns-collapse-id
and thread-id
.
我们希望具有相同apns-collapse-id
的多个远程通知将合并.这没有发生.
We are expecting the multiple remote notifications with same apns-collapse-id
to merge. It is not happenning.
很少有人建议APNS崩溃不是免费的,我必须实施UNNotificationContentExtension
并手动处理通知.我知道我可以添加和删除已发布的本地通知,但不确定如何更新已发布的远程通知.
Few people suggested APNS collapse does not come for free and I have to implement UNNotificationContentExtension
and handle the notifications manually. I know I can add and remove local notification already posted but not really sure how to update the already posted remote notification.
这是我们的有效载荷的样子
Here is how our payload looks like
payload {
"aps": {
"alert": {
"title": "Some title : ",
"body": "Some body text"
},
"sound": "default",
"payload": {
"target": {
"some key" : "Some value"
},
"thread_id": "Some_string_155863",
},
"apns-collapse-id": "Some_string_155863",
"mutable-content": 1,
"thread-id": "Some_string_155863",
"badge": 33
},
"thread-id": "Some_string_155863",
"apns-collapse-id": "Some_string_155863",
"mutable-content": 1
}
您可以看到apns-collapse-id和thread-id在JSON中重复了多次,因为我们不确定在哪里准确放置它们
as you can see apns-collapse-id and thread-id are repeated multiple times in JSON because we aren't sure where exactly to have them
我们尚未使用HTTPS/2,但我相信iOS 10通知仍支持旧版HTTPS.我不是一个真正的网络人,所以我不太了解这些东西.忽略我对Https和Http2的傲慢态度
We are not using HTTPS/2 yet, but I believe iOS 10 notfication still supports legacy HTTPS. I am not really a network guy so I don't understand these things completely. Ignore my arrogance towards Https and Http2
有人能设法获得apns-collapse-id吗?请帮忙.
Has anybody managed to get apns-collapse-id to work ? Please help.
推荐答案
apns-collapse-id
是请求标头,因此您需要使用HTTP服务而不是旧式二进制接口.
apns-collapse-id
is a request header, so you need to use the HTTP service and not the legacy binary interface.
这篇关于apns-collapse-id不合并多个通知iOS 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!