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

Data not being received by client #156

Closed aryehischechter closed 8 years ago

aryehischechter commented 8 years ago

After upgrading from 0.9.12 to 0.11.1 clients have stopped receiving the data.

sample code is:

var gcm = require('node-gcm'),
     gcmMessage = new gcm.Message();
var sender = new gcm.Sender(KEY, {
    timeout: TIMEOUT
});

gcmMessage.data = {
        j: "Will we get this?",
        id: "abcd-efgh"
};

sender.send(gcmMessage, tokensArray, 4, callback);

the client only receives:

 flags: 16 action: com.google.android.c2dm.intent.RECEIVE
          key: [from] value: [ABCXYZ]
          key: [android.support.content.wakelockid] value: [11]
          key: [collapse_key] value: [do_not_collapse]
aryehischechter commented 8 years ago

found the changes to send, where you do toJSON, which will ignore the way we were adding data to the gcm message object. I should be using addData. closing.

hypesystem commented 8 years ago

Glad you found the change :)