推送通知到iOS成功,但显示为“失败”

时间:2017-07-13 12:49:40

标签: ios push-notification apple-push-notifications

我正在使用APN模块向iOS发送推送通知。这一切看起来都很好但是我总是'失败'作为响应结果发送消息之后实际上我实际上在电话上得到了消息(所以它不应该'失败')。

为什么回复显示为“失败”以及如何解决?

var apn = require('apn');
var options = {
  token: {
    key: "keys/AuthKey_123.p8",
    keyId: "123",
    teamId: "teamA"
  },
  production: false
};

var json_message = {
    "aps" : {
        "alert" : {
            "title" : "This is title",
            "body" : "This is body",
        }
    };

var apnProvider = new apn.Provider(options);
var deviceToken = "device token";

var note = new apn.Notification();
note.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
note.badge = 3;
note.sound = "ping.aiff";
note.alert = json_message.aps.alert.body;
note.payload = json_message;
note.topic = "com.test";

apnProvider.send(note, deviceToken).then( (result) => {
    console.log(result);
    console.log("\n*** Response: ***\n");
    console.log(JSON.stringify(result, null, 2));
});

0 个答案:

没有答案