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 208 forks source link

unsure about send callback response #197

Closed molecular closed 8 years ago

molecular commented 8 years ago

Hi, I'm using the send() function to send a batch of notifications to a bunch of devices. In the callback response there is a results array.

The objects in those array sometimes contain a "message_id" and sometimes a "registration_id" in addition. Example:

Sat, 02 Jan 2016 06:01:56 GMT dispatcher result # 0 :  { message_id: '0:1451714516452726%991921c6f9fd7ecd' }
Sat, 02 Jan 2016 06:01:56 GMT dispatcher result # 1 :  { message_id: '0:1451714516452322%991921c6f9fd7ecd' }
Sat, 02 Jan 2016 06:01:56 GMT dispatcher result # 2 :  { message_id: '0:1451714516453544%991921c6f9fd7ecd' }
Sat, 02 Jan 2016 06:01:56 GMT dispatcher result # 3 :  { registration_id: 'APA91bFvcBhtpcehCtmkVRfgyqddluk...',
  message_id: '0:1451714516452887%991921c6f9fd7ecd' }
Sat, 02 Jan 2016 06:01:56 GMT dispatcher result # 4 :  { message_id: '0:1451714516454221%991921c6f9fd7ecd' }
Sat, 02 Jan 2016 06:01:56 GMT dispatcher result # 5 :  { message_id: '0:1451714516454984%991921c6f9fd7ecd' }
Sat, 02 Jan 2016 06:01:56 GMT dispatcher result # 6 :  { message_id: '0:1451714516452930%991921c6f9fd7ecd' }
Sat, 02 Jan 2016 06:01:56 GMT dispatcher result # 7 :  { message_id: '0:1451714516453712%991921c6f9fd7ecd' }

(registration ID shortened) The documentation is a bit thin on this. What is the meaning of the fact that an object is containing a registration_id vs. just a message_id?

hypesystem commented 8 years ago

We return exactly what GCM returns. The relevant documentation can be found here.

The relevant section is:

registration_id: Optional string specifying the canonical registration token for the client app that the message was processed and sent to. Sender should use this value as the registration token for future requests. Otherwise, the messages might be rejected.

eladnava commented 8 years ago

@molecular Just to clarify, it means that the registration token for that specific device has changed, and that the new one is contained within the registration_id property in the GCM response. You should overwrite the registration ID stored in your server for that device with the one in the response.

molecular commented 8 years ago

I see.

thanks guys, sent a small donation to the address in readme.md

eladnava commented 8 years ago

@molecular Thank you!