在iOS中使用数据有效负载时接收低优先级通知

时间:2018-10-05 00:51:47

标签: ios firebase firebase-cloud-messaging

我有一个问题,我不确定这是否是错误。我知道有效负载有两种,通知数据。这是问题所在:

默认有效载荷:

{
    "content_available":true,
    "priority":"high",
    "notification":{
        "title":"this is the title.",
        "body":"this is the body.",
        "iconURL":"http://www.shutterangle.com/wp-content/uploads/2012/04/bladerunner.jpg",
        "route":"home",
        "bigPictureURL":"http://www.shutterangle.com/wp-content/uploads/2012/04/bladerunner.jpg"
    },
    "to":token
}

这可以在前景,背景下运行,甚至可以杀死应用程序,甚至重启设备都很棒。当我查看xcode中的日志时,发现“ priority”:“ high” 被准确地解释了。这是日志:

Oct  5 07:29:13 testdevice-iPhone apsd[112] <Notice>: Dispatching high priority message: <xpc object>
Oct  5 07:29:13 testdevice-iPhone SpringBoard(UserNotificationsServer)[55] <Notice>: Received incoming message on topic com.testing.mytestapp at priority 10

这就是为什么默认的远程推送通知以不同的应用程序/设备状态(前景,背景,已终止等)到达我的测试应用程序的原因。

自定义有效载荷:

{
    "content_available":true,
    "priority":"high",
    "data":{
        "title":"this is the title.",
        "body":"this is the body.",
        "iconURL":"http://www.shutterangle.com/wp-content/uploads/2012/04/bladerunner.jpg",
        "route":"home",
        "bigPictureURL":"http://www.shutterangle.com/wp-content/uploads/2012/04/bladerunner.jpg"
    },
    "to":token
}

此功能仅适用于前台和后台,当您终止应用程序或重新启动设备时,它将不再接收。当我发送远程推送通知后查看xcode日志时,这就是我发现的内容:

Oct  5 07:32:33 testdevice-iPhone apsd[112] <Notice>: <private> deleting low-priority incoming messages for topic <private> environment development

Oct  5 07:32:33 testdevice-iPhone apsd[112] <Notice>: Dispatching low priority message: <xpc object>

Oct  5 07:32:33 testdevice-iPhone SpringBoard(UserNotificationsServer)[55] <Notice>: Received incoming message on topic com.testing.mytestapp at priority 1

我不知道将有效负载设置为高时将其解释为低优先级的原因。有人遇到这个问题吗?建议非常感激。

谢谢。

0 个答案:

没有答案