iOS “thread-id” doesn't group push notificatio

2019-01-28 02:41发布

问题:

From the documentation:

thread-id | string | When displaying notifications, the system visually groups notifications with the same thread identifier together. For remote notifications, the value of the threadIdentifier property is set to the value of this request header.

Our push notification payloads:

{
    aps =     {
        alert =         {
            body = "Leeroy J asked you: Test Push Notification";
        };
        badge = 12;
        sound = default;
        "thread-id" = 9150;
    };
    n = "6kQ/0x6556";
    r = 9150;
}

{
    aps =     {
        alert =         {
            body = "Leeroy J re: Test Push Notification";
        };
        badge = 13;
        sound = default;
        "thread-id" = 9150;
    };
    n = "6l8/0x6582";
    p = 7197;
    r = 9150;
}

Here's what it looks like in Message Center:

I expected them to be visually different than other notifications... either that or grouped together when other notifications come in between. In our testing, neither is the case.

What am I doing wrong? Or am I misunderstanding this feature?

回答1:

Unfortunately, you don't get this for free. You need to create a Notifictation UI extension, and implement your own UI(in this case it's a conversation UI), and update the UI when receive new notification with same thread-id.



回答2:

https://medium.com/the-guardian-mobile-innovation-lab/how-to-replace-the-content-of-an-ios-notification-2d8d93766446:

says to use apns-collapse-id instead



回答3:

I had this problem with Firebase not using apns-collapse-id. How I solved it was to use key instead of certificates. You can find the key right under the certificates in developer.apple.com . It now uses one "row" of notification and puts the last notification from group into that row. Advanced features such as replacing content would have the necessity to use notification ui extension.