Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
459 views
in Technique[技术] by (71.8m points)

apns-collapse-id not merging multiple notifications iOS 10

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.

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.

We are expecting the multiple remote notifications with same apns-collapse-id to merge. It is not happenning.

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
}

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

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

Has anybody managed to get apns-collapse-id to work ? Please help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

apns-collapse-id is a request header, so you need to use the HTTP service and not the legacy binary interface.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...