应用程序:didReceiveRemoteNotification:fetchCompletionHandler 未调用 [英] application:didReceiveRemoteNotification:fetchCompletionHandler Not Called

查看:38
本文介绍了应用程序:didReceiveRemoteNotification:fetchCompletionHandler 未调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当应用程序被强制退出时,application:didReceiveRemoteNotification:fetchCompletionHandler 函数似乎没有被调用.我的印象是无论应用程序处于什么状态都会调用该函数,但似乎只有在应用程序已经在后台运行时才会调用它.如果应用程序尚未使用新的 iOS 7 远程通知后台模式运行,有没有办法在后台唤醒应用程序?

It appears the function application:didReceiveRemoteNotification:fetchCompletionHandler is not called when the app has been forcefully quit. It was my impression that the function would be invoked no matter what state the app was in, but it appears that it is only called if the app is already running in the background. Is there a way to wake up an app in the background if it is not already running using the new iOS 7 remote notification background mode?

推荐答案

application:didReceiveRemoteNotification:fetchCompletionHandler: 即使应用程序已暂停、根本未运行、后台运行或处于活动状态,也会被调用.另外值得注意的是,该方法仅适用于 iOS 7.这是 苹果文档.

application:didReceiveRemoteNotification:fetchCompletionHandler: gets called even if the app is suspended, not running at all, backgrounded, or active. Also worth noting that the method is iOS 7 only. Here is the apple documentation.

但是,如果应用被强行关闭(即通过应用切换器杀死),应用将不会启动.(请参阅SO 答案)我在 iOS 7.1 上再次检查了这个问题,看看他们是否修复了这个问题,但如果应用程序被手动杀死,应用程序将不会被唤醒并且 application:didReceiveRemoteNotification:fetchCompletionHandler: 不会被调用

HOWEVER if the app was forcibly closed (i.e. by killing with the app switcher), the app will not be launched. (see SO answer) I checked this again on iOS 7.1 to see if they fixed this, but it still remains the case that if the app is killed manually, app will NOT be woken up and application:didReceiveRemoteNotification:fetchCompletionHandler: will not be called

当接收推送时,应用程序仅在需要时"被唤醒以调用 application:didReceiveRemoteNotification:fetchCompletionHandler: 方法(即您必须在其中设置content-available"标志推送通知负载.请参阅 SO 答案).如果用户然后通过点击通知打开应用程序,该方法将被再次调用.

When receiving the push, the app is only woken up only "if needed" to call the application:didReceiveRemoteNotification:fetchCompletionHandler: method (i.e. you have to set the "content-available" flag within the push notification payload. See SO answer). The method will be called again if the user then opens the app by tapping the notification.

没有在 iOS 8 上检查过这个.还有其他人吗?

haven't checked this on iOS 8. Has anyone else?

这篇关于应用程序:didReceiveRemoteNotification:fetchCompletionHandler 未调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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