Google云消息传递(fake_message_id)

我有node.js服务器:

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); }); 

我有一个:

{multicast_id:-1,成功:1,失败:0,canonical_ids:0,结果:
[{message_id:fake_message_id'}]}

而消息不会发送给接收者。

fake_message_id是什么意思?

       

网上收集的解决方案 "Google云消息传递(fake_message_id)"

看看你的代码,我可以看到你设置消息属性dryRun为true:

 message.dryRun = true; 

通过这样做,您告诉Google服务器这是一个testing消息,以查看是否所有密钥都已正确configuration。 如果您注释掉该行,或者将该属性设置为false(其默认值),则该消息将作为真实消息处理。

DryRun的答案也很容易被他们的multicast_id发现,它总是-1