Google Cloud Messaging (fake_message_id)

I have a node.js server:

var gcm = require('node-gcm'); // create a message with default values var message = new gcm.Message(); // or with object values var message = new gcm.Message({ collapseKey: 'demo', delayWhileIdle: true, timeToLive: 3, data: { key1: 'message1', key2: 'message2' } }); var sender = new gcm.Sender('AIzaSyChp2jTQsgPkLaaVgFh6yoovu1Td7tuQMo'); var registrationIds = []; // OPTIONAL // add new key-value in data object message.addDataWithKeyValue('key1','message1'); message.addDataWithKeyValue('key2','message2'); // or add a data object message.addDataWithObject({ key1: 'message1', key2: 'message2' }); // or with backwards compability of previous versions message.addData('key1','message1'); message.addData('key2','message2'); message.collapseKey = 'demo'; message.delayWhileIdle = true; message.timeToLive = 3; message.dryRun = true; // END OPTIONAL // At least one required registrationIds.push('APA91bGV0W6lgapC07aHc-sQdd462f_lCoUY0r5mqVtdFX1ZfK31njMUeyVXXXXXXXXXXXXXXXXXXXXXXXXX0SiAp29dkyxdJ5Y8Cl2tO1aih0KeViA9hK3Q47atoU8qsD6ITbg'); /** * Params: message-literal, registrationIds-array, No. of retries, callback-function **/ sender.send(message, registrationIds, 4, function (err, result) { console.log(result); }); 

I got:

{multicast_id: -1, success: 1, failure: 0, canonical_ids: 0, results:
[{message_id: fake_message_id '}]}

And the message is not sent to the recipients.

What does fake_message_id mean?

+5
source share
1 answer

Looking at my code, I see that you set the dryRun property of the message to true:

 message.dryRun = true; 

By doing this, you tell Google servers that this is a test message to check that all keys are configured correctly. If you comment out this line or set the property to false (its default value), the message will be treated as a real message.

DryRun's answers are also easily recognized by their multicast_id, which will always be -1

+20
source

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


All Articles