iOS 7 中的静默推送通知不起作用 [英] Silent Push Notification in iOS 7 does not work

查看:33
本文介绍了iOS 7 中的静默推送通知不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 WWDC 2013 的多任务新功能"演示中,有一节是关于静默推送通知的.看起来很直接.根据介绍,如果您发送 APS 负载时仅将 content-available 设置为 1,则用户将不会收到通知.

In the WWDC 2013's "What's New with Multitasking" presentation, there is a section about Silent Push Notifications. It seems straight forward. According to the presentation, if you send the APS payload with just the content-available set to 1, users will not be notified of the notification.

// A. This doesn't work
{ 
  aps: { 
          content-available: 1 
       }
}

我的测试表明这不起作用,因为没有收到推送.但是如果我包含 sound 属性但排除 alert 属性,它就可以工作(虽然不再沉默).

My testing shows that this does not work as no push is received. But if I include the sound attribute but exclude the alert attribute, it works (though not silent anymore).

// B. This works
{ 
  aps: {
          content-available: 1,
          sound: "default"
       }
}

但是,如果我将声音属性更改为播放无声音频,则可以模拟无声推送.

However, if I change the sound attribute to play a silent audio, I can mimic a silent push.

// C. This works too.
{ 
  aps: {
          content-available: 1,
          sound: "silence.wav"
       }
}

有谁知道:

  1. 如果这是一个错误?
  2. 如果假设 B 或 C 被视为远程通知是正确的(而不是需要声音属性的静默推送的错误)?如果是这样,这意味着它不会像 Silent Pushes 那样受到速率限制……Apple 可能会解决这个问题.所以我可能不应该依赖它.
  3. 速率限制是多少(N 次每 X 秒推送一次,等等)?

提前致谢.

使用更多信息进行编辑

对于 A,应用程序的状态无关紧要.永远不会收到通知.

For A, the state of the application does not matter. Notification is never received.

似乎 B 和 C 仅在将属性和值括在引号中时才有效,如下所示.

It seems like B and C only work if you enclose the attributes and values in quotes, like below.

{"aps":{"content-available": 1, "sound":"silent.wav"}}

无论状态如何,通知都会到达application:didReceiveRemoteNotification:fetchCompletionHandler:.

And the notification arrives in application:didReceiveRemoteNotification:fetchCompletionHandler: regardless of state.

推荐答案

这也有效,到达时不播放声音:

This works also and does not play a sound when it arrives:

{
    aps = {
        "content-available" : 1,
        sound : ""
    };
}

编辑

遇到此问题的人可能想查看此链接.我一直在参与 Apple 开发者论坛上的一个帖子,该帖子讨论了所有应用程序状态以及何时接收和未接收到静默推送.

People having this problem may want to check out this link. I have been participating in a thread on Apple's Developer forum that goes over all app states and when silent pushes are received and not received.

这篇关于iOS 7 中的静默推送通知不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆