nodejs给苹果客户端(iphone/ipad)发送推送apn
发布于 11 年前 作者 dawnwdf 10169 次浏览 最后一次编辑是 8 年前

如题: 参考资料http://iosshare.cn/?p=1133 其中制作cert.pem 和 key.pem都成功 代码使用的是

var options = {
cert: '../pem/apns-prod-cert.pem',                 /* Certificate file path */
key:  '../pem/apns-prod-key.pem',                  /* Key file path */
gateway: 'gateway.sandbox.push.apple.com',/* gateway address gateway.push.apple.com, port 2195*/
port: 2195,                       /* gateway port */
errorCallback: errorHappened ,    /* Callback when error occurs function(err,notification) */
};

	var apnsConnection = new apns.Connection(options);
var myDevice = new apns.Device(goodToken);
var note = new apns.Notification();
note.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
note.badge = 1;
note.sound = 'ping.aiff';
note.alert = 'You have a new message';
note.payload = {'messageFrom': 'Caroline'};
apnsConnection.pushNotification(note,myDevice);
note.device = myDevice;
apnsConnection.sendNotification(note);

当前确定这段代码是执行了的,没有问题,但是我的iphone设备无法接收到通知。 请问有没有哪位大侠曾经做过类似的东西,指点一二!

4 回复

确定token正确吗 有没有把中间的空格去掉 发送的时候又什么输出信息么

token是正确的,空格已经去掉, 使用apn 时输出过

send:5423!!!(这里是我的token) open socket 这样两行文字在终端里

现在我node服务端已经把通知推送出去了,而且没报任何错误,但是手机就是接受不到,问什么?

@dawnwdf 终端收不到啊,请问遇到这个情况吗?

回到顶部