Phonegap Pushnotification + node -gcm: group notifications

I have something like this in a Node application:

var sender = new gcm.Sender("XPTO"); var registrationIds = ["whatever"]; ... var message = new gcm.Message({ data: { avatar: body_data.avatar, message: body_data.message } }); sender.send(message, registrationIds, 4, function (err, result) { console.log("success"); }); 

It works great, a notification arrives and goes to the tray if the application does not open. But if I send a new notification to the same registration ID, the old notification will be “updated” (or deleted) and only the new one will be shown.

If I add a random integer as parameter in notId

 message.addData("notId", parseInt(Math.random() * 25)); 

notifications are saved in the tray, but then the tray starts showing several notifications. Is there a way to group notifications?

+6
source share
1 answer

Android devices group the same notifications. If you set different collapseKey for each type of notifications, they will not be grouped with others. You can have no more than 4 different collapseKeys at a time, visible to the user in the tray.

0
source

Source: https://habr.com/ru/post/975736/


All Articles