简体   繁体   English

iOS8-在有效负载中添加“ sound”属性之前,无声推送通知不起作用

[英]iOS8 - Silent push notifications doesn't work until add “sound” attribute in payload

I have an application with Push notifications enabled.I add background modes, add logic for registration for both iOS versions and they should work equally. 我有一个启用了Push通知的应用程序。我添加了后台模式,添加了两个iOS版本的注册逻辑,它们应该可以平等地工作。 In iOS7 this works as expected (Application "wake up" and fetch data): 在iOS7中,这按预期工作(应用程序“唤醒”并获取数据):

"customJson":{ },
"aps":{"content-available":1}

In iOS8 to do the same thing I have to add empty sound,otherwise didReceiveRemoteNotification: fetchCompletionHandler: method is not executed: 在iOS8中,要做同样的事情,我必须添加空的声音,否则didReceiveRemoteNotification:fetchCompletionHandler:方法不会执行:

"customJson":{ },
"aps":{"content-available":1,sound:""}

For registration I use workaround from this question. 对于注册,我使用问题的解决方法。 Why this happen,any ideas? 为什么会发生这种情况?

Had the same problem before, seems like this is a bug with silent push notifications. 之前有过相同的问题,似乎这是带有静默推送通知的错误。 I added 我加了

sound:""

like you did and it worked. 就像您所做的一样,而且效果很好。

What I've learned is, that silent notifications will not be handled by the system when the user fore-quit'ed the app (killed via swipe on task manager): https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:didReceiveRemoteNotification:fetchCompletionHandler : So if the user killed the app, it shouldn't do anything in the background anymore. 我了解到的是,当用户退出应用程序(通过在任务管理器上轻扫而杀死)时,系统不会处理无提示通知: https : //developer.apple.com/library/prerelease/ ios / documentation / UIKit / Reference / UIApplicationDelegate_Protocol / index.html#// apple_ref / occ / intfm / UIApplicationDelegate / application:didReceiveRemoteNotificationfetchCompletionHandler :因此,如果用户终止了该应用程序,则该应用程序不应再在后台执行任何操作。 This makes sense from a user's perspective. 从用户的角度来看,这是有道理的。

Have you tried adding remote-notification to Info.plist UIBackgroundModes array? 您是否尝试过将远程通知添加到Info.plist UIBackgroundModes数组? You need to have that entry for silent notifications to work. 您需要具有该条目才能使无提示通知起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM