0
我想通过UnifiedPushServer in Node.js发送消息给我的android设备。无法通过UnifiedPushServer推送消息Node.js
我想:
var agSender = require("unifiedpush-node-sender").AeroGear,
url = "http://192.168.1.9:8080/ag-push",message="Hello";
settings = {
applicationID: "8f39bc13-acb7-4d34-baa1-c2343f8ebff4",
masterSecret: "2a1a901a-34f7-40c9-b6d0-50129c4794ae"
};
agSender.Sender(url).send(message, settings).on("success", function(response) {
console.log("success called", response);
}).on("error",function(error){
console.log(error);
});
并开始运行,我得到这个代码:
D:\node>node server.js
events.js:74
throw TypeError('Uncaught, unspecified "error" event.');
^
TypeError: Uncaught, unspecified "error" event.
at TypeError (<anonymous>)
at emit (events.js:74:15)
at doEvent (D:\node\node_modules\unifiedpush-node-sender\lib\unifiedpush-nod
e-sender.js:25:14)
at ClientRequest.<anonymous> (D:\node\node_modules\unifiedpush-node-sender\l
ib\unifiedpush-node-sender.js:44:25)
at ClientRequest.g (events.js:180:16)
at ClientRequest.emit (events.js:95:17)
at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1692:21)
at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23
)
at Socket.socketOnData [as ondata] (http.js:1587:20)
at TCP.onread (net.js:527:27)
可能是什么问题呢?
的问题是与消息格式。需要JSON {} – writeToBhuwan 2014-09-22 17:27:00
感谢您的帮助!在我的代码中也修复了.Aerogear :) – writeToBhuwan 2014-09-22 17:27:36