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

我得到了:



并且消息不会发送给接收者。

fake_message_id是什么意思?

最佳答案

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

message.dryRun = true;

这样,您就告诉Google服务器这是一条测试消息,以查看是否正确配置了所有密钥。
如果注释掉该行,或将该属性设置为false(其默认值),则该消息将被视为真实消息。

DryRun答案也很容易通过它们的multicast_id发现,该值始终为-1

08-20 03:54