apns-collapse-id 不合并多个通知 iOS 10 [英] apns-collapse-id not merging multiple notifications iOS 10

查看:19
本文介绍了apns-collapse-id 不合并多个通知 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-idthread-id 的负载.不幸的是,由于网上没有太多内容解释这些键的实际工作原理,为了安全起见,我们对 apns-collapse-idthread-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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆