通过Node.js发送APN

通过Node.js发送APN,node.js,apple-push-notifications,Node.js,Apple Push Notifications,我正在按照上的说明发送消息。它似乎工作正常,除非我将connectionTimeout设置为1000,否则进程不会返回 我的问题:我应该设置connectionTimeout以便进程返回并继续代码,还是应该做其他事情 这是我的密码: var apn = require ('apn/index.js'); var options = { cert: './cert.pem', key: './key.pem', connectionTimeout:

我正在按照上的说明发送消息。它似乎工作正常,除非我将connectionTimeout设置为1000,否则进程不会返回

我的问题:我应该设置connectionTimeout以便进程返回并继续代码,还是应该做其他事情

这是我的密码:

var apn = require ('apn/index.js');

var options = {
        cert: './cert.pem',
        key: './key.pem',
        connectionTimeout: 1000,
        production: false
};
var apnConnection = new apn.Connection(options);

apnConnection.on('disconnected', function() {
    console.log("Disconnected from APNS");
});

var token       = '<my token>';

var myDevice    = new apn.Device(token);

var note = new apn.Notification();

note.expiry             = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
note.badge              = 777;
note.retryLimit         = 1;
note.sound              = "ping.aiff";
note.alert = "\u2709 Sorry ..... ";
note.payload            = {'messageFrom': 'My Payload'};

apnConnection.pushNotification(note, myDevice);

你明白了吗?