3

我创建了一个 javascript 文件(notification.js)。我使用 node.js 在命令node notification.js中启动 web 服务。我收到错误消息Can not file module node-gcm。我之前使用命令npm install node -gcm 为 node.js 下载了 node-gcm 。我不知道如何处理这个问题。请帮我。

通知.js

var gcm = require('node-gcm');
//var gcm = require('../gcm.js');

var message = new gcm.Message();
var sender = new gcm.Sender('AIzaSyB8IAgyo9DJbmGiVISnCCoxcQRD7em6KfI');
var registrationIds = [];

message.addData('title','My Game');
message.addData('message','Your turn!!!!');
message.addData('msgcnt','1');
message.collapseKey = 'demo';
message.delayWhileIdle = true;
message.timeToLive = 3;

// At least one token is required - each app registers a different token
     registrationIds.push('APA91bHg7QEO3h44OCrBAb6yoHEvNvVSrRRcJjufS5fduCw2YhC83BZ9eqlxYS9PbKIAoFrmK-rvNEQ-CxrAjy4Wy13CRt5or1h7kG9XDRg2Tcy4zx8EpGOYLybmgnLDmVVvTJF4PR9Y');

server.listen(4040)
sender.send(message, registrationIds, 4, function (result) {
console.log(result);
});
4

0 回答 0