iOS 7中的静默推送通知不起作用 [英] Silent Push Notification in iOS 7 does not work
问题描述
在WWDC 2013的多任务新功能演示中,有一节关于静音推送通知。这似乎是直截了当的。根据演示文稿,如果您将APS有效负载仅发送到内容可用设置为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
}
}
我的测试显示这不起作用,因为没有收到推送。但是,如果我包含声音属性但排除了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"
}
}
有谁知道:
- 如果这样一个错误?
- 如果假设B或C被视为远程通知是正确的(而不是Silent Push的错误,你需要一个声音属性)?如果是这样,这意味着它没有像Silent Pushes那样的速率限制...... Apple可能会解决这个问题。所以我可能不应该依赖它。
- 什么是速率限制(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"}}
通知到达应用程序: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屋!