我正在使用node-apn向我的设备发送推送通知。无论我何时尝试,我都会得到以下结果:
{ sent: [],
failed:
[ { device: '****',
status: '400',
response: [Object] } ] }我相当确定我的设备令牌是正确的。有没有办法找到更多关于为什么会发生这个错误的信息。“response”-if中是否有信息,如何获取?获取此处列出的一个错误字符串(如"BadCollapseId“) (https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html)会很有帮助。
下面是我的node.js代码以供参考。
var deviceToken = "***";
var notification = new apn.Notification();
notification.topic = '*****';
notification.alert = "HI DER";
notification.payload = {id: 3};
apnProvider.send(notification, deviceToken).then(function(result) {
console.log(result);
});这个应用程序是使用ionic 2构建的,但我不认为这会有什么不同。
谢谢!
发布于 2017-07-12 07:40:46
基本上我所需要的就是这一行:
console.log(result.failed);而不是
console.log(result);这给了我代码"DeviceTokenNotForTopic“,我可以从那里开始!
https://stackoverflow.com/questions/45043402
复制相似问题