我正在尝试通过UnifiedPushServer in Node.js向我的Android设备发送消息。
我试过了:
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)
可能是什么问题?
答案 0 :(得分:0)
您不再需要.AeroGear
var agSender = require( "unifiedpush-node-sender" ).AeroGear