0

I am using apn push notificaitons from node server. I want to group same nature of notifications together. For that I am using threadId parameter but its still not grouping the notifications.

Here is my server side code:

var apnOptions = {

  token: {
    key:    "certificates/F5TRRQ26V.p8",
    keyId:  "F5TRRQ26V",
    teamId: "4ZGSRKDXH"
  },
  production: false 
};

var apnProvider = new apn.Provider(apnOptions);
var note        = new apn.Notification();

note.expiry     = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
note.badge      = 3;
note.sound      = "ping.aiff";
note.alert      = "\uD83D\uDCE7 \u2709 You have a new message";
note.payload    = { 'messageFrom': 'John Appleseed' };
note.topic      = "com.example.myapp";
note.threadId   = "870";

apnProvider.send(note, '5DA3C319EB50GDDGGAAA333DC9FE6DB240C34C66CBF1E547CD8307DCA15').then( (result) => {

  console.log(result); 
});

On IOS app side I am receiving this:

User Info =  [AnyHashable("thread-id"): 870, AnyHashable("threadId"): 870, AnyHashable("aps"): {
    alert = "\Ud83d\Udce7 \U2709 You have a new message";
    badge = 3;
    sound = "ping.aiff";
    "thread-id" = 870;
}, AnyHashable("messageFrom"): John Appleseed]

But still the notifications are not being grouped.

StormTrooper
  • 1,731
  • 4
  • 23
  • 37
  • are you sure you use iOS 12? – Vyacheslav Jan 08 '19 at 11:50
  • I would suggest try to use note.threadId = "some-prefix-string-870"; for testing – Vyacheslav Jan 08 '19 at 11:51
  • Yes my ios current version is 12.1.2 – StormTrooper Jan 08 '19 at 11:51
  • @Vyacheslav I tried to use to use note.threadId = "some-prefix-string-870"; its not working either. – StormTrooper Jan 08 '19 at 11:56
  • Have you tried "apns-collapse-id" instead? https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW13 – NeverHopeless Jan 08 '19 at 11:59
  • @NeverHopeless yes I tried collapseId = 870, this is something else, this will only show the first ever notification, after that it will just make a notification sound but the state of notification will remain the same as of very first one. In simple words, it doesnt make any difference in the ui, you will keep seeing the first notification as it was. after that you only listen the sound of new notification. – StormTrooper Jan 08 '19 at 12:02
  • @StormTrooper, you want grouping but most recent on top ? – NeverHopeless Jan 08 '19 at 13:33

0 Answers0