【问题标题】:Will didReceiveRemoteNotification called in foreground mode when content-available set as true in payload?当内容可用在有效负载中设置为 true 时,是否会在前台模式下调用 didReceiveRemoteNotification?
【发布时间】:2016-07-12 14:43:38
【问题描述】:

当应用程序在前台运行时,当负载中的"content-available":true 时,推送通知未收到。但是当应用不在前台运行时会收到通知。

我还为后台获取和远程通知添加了“必需的后台模式”。我正在使用didReceiveRemoteNotification:fetchCompletionHandler: 方法处理推送消息,该消息在应用未运行时调用,但仅在前台模式下调用。

我想从服务器下载一些内容,即使应用程序正在使用静默推送通知在前台运行。有没有其他方法可以在前台模式下使用"content-available":true payload 接收推送通知?

谢谢!

【问题讨论】:

    标签: ios apple-push-notifications


    【解决方案1】:

    您可能已经实现了 didReceiveRemoteNotification:。改为实现 didReceiveRemoteNotification:fetchCompletionHandler:。

    【讨论】:

    • 我只使用didReceiveRemoteNotification:fetchCompletionHandler: 方法。请看我上面的修改。
    • 你确定你的payload不包含aps字典中的alert、sound或badge吗?
    • 是的,我确定我只在 aps dic 中包含了 "content-available":true。
    • 如果它包含 content-available 和 alert、sound、badge 之一,则不能保证它会正常工作。所以请确保你没有最后 3 个。
    猜你喜欢
    • 1970-01-01
    • 2015-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-09
    • 2012-04-05
    • 1970-01-01
    相关资源
    最近更新 更多