ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.3k stars 206 forks source link

Grouping push notification messages #207

Closed pputhran closed 8 years ago

pputhran commented 8 years ago

Hi,

Whats the best way to group PN messages ? For instance: in whatsapp when I am part of group conversation and more than one people/friends send a message, I get a consolidated notification saying 2 messages. How do I do that using node-gcm ?

eladnava commented 8 years ago

@pputhran You can use the collapse_key for that:

https://developers.google.com/cloud-messaging/http-server-ref

This parameter identifies a group of messages (e.g., with collapse_key: "Updates Available") that can be collapsed, so that only the last message gets sent when delivery can be resumed. This is intended to avoid sending too many of the same messages when the device comes back online or becomes active (see delay_while_idle). Note that there is no guarantee of the order in which messages get sent.

Supply it to node-gcm as specified in this example: https://github.com/ToothlessGear/node-gcm#usage

hypesystem commented 8 years ago

Alternatively, if you use the data (and not the notification) field to send your data, you can create the notification client-side and completely determine the content based on available knowledge :smile:

This seems to be more of an issue with the format of GCM than the specific library, so I am closing it :smile: Feel free to ask more questions on the issue, though.