Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 658
Sandeep Bhandari Avatar asked Jun 15 '17 07:06

Sandeep Bhandari


People also ask

Why push notification is not working for iOS?

You can fix an iPhone that's not getting notifications by restarting it or making sure notifications are turned on. You should also make sure your iPhone is connected to the internet so apps can receive notifications. If all else fails, you should try resetting the iPhone — just make sure to back it up first.

What is APNs collapse ID?

The APNs request header key for the collapse identifier is apns-collapse-id and is defined in Table 6-2. 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.

How do I check my APN push notifications?

Sending a test Android push notificationClick on Settings and open Mobile Apps. Click on the Android App and make sure the Firebase API key has been configured. Click on Test Push and enter the device token for your test device. Add a test payload and send the test.

What is rich push notification in iOS?

Rich push notifications are short pop-up messages sent to a user's device with a rich media attachment such as an animated GIF, video, or audio. They allow you to communicate with your customers in an inviting way even when they're not actively using your app or visiting your website.


1 Answers

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

like image 182
user8262578 Avatar answered Nov 10 '22 12:11

user8262578