杀死应用后,后台获取功能无效 [英] Background fetch is not working after killing the app

查看:106
本文介绍了杀死应用后,后台获取功能无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过后台获取从url获取数据。我的func尝试获取数据,如果有新数据,它会发送本地通知。当我最小化应用程序时,后台提取工作大约10 - 20分钟后工作。但是,当我杀了应用程序(双击主页按钮并关闭应用程序)它不起作用。我等了大约1个小时但是没用。我在android中使用后台服务,它正在成功运行。有没有办法从网址获取数据并在应用关闭时发送本地通知?我正在使用Xcode 6和swift 1.2

I'm trying to get data from url with background fetch. My func tries to get data and if there is a new data, it sends local notification. Background fetch works after about 10 - 20 minutes when i minimize the app. But when i kill the app (double click home button and close app) it doesn't work. I waited about 1 hour but it didn't work. I am using background service in android and it is working successfully. Is there any way to get data from url and send local notification when app is closed? I am using Xcode 6 and swift 1.2

推荐答案

在用户将其杀死后,您的应用中不会发生后台提取多任务UI。这是设计的。

The Background Fetching will NOT happen in your app after the user has killed it in the multitasking UI. This is by design.

看看 Apple的文档提及:


支持后台执行的应用程序可能会被系统
重新启动以处理传入事件。如果某个应用因任何原因因用户强制退出而被终止
,系统会启动应用...

Apps that support background execution may be relaunched by the system to handle incoming events. If an app is terminated for any reason other than the user force quitting it, the system launches the app...


在大多数情况下,系统在用户退出强制
后不会重新启动应用程序。一个例外是位置应用程序,在iOS 8和
之后,在用户强行退出后重新启动。但是,在其他
的情况下,用户必须明确启动应用程序或重新启动
设备才能将应用程序自动启动到系统的
后台。

In most cases, the system does not relaunch apps after they are force quit by the user. One exception is location apps, which in iOS 8 and later are relaunched after being force quit by the user. In other cases, though, the user must launch the app explicitly or reboot the device before the app can be launched automatically into the background by the system.

正如您在文档中注意到的那样,只有当应用程序被强制终止时才重新启动,只有1个例外:使用位置服务。不幸的是,这不适用于您。

As you noticed in the documentation, there's only 1 exception when the app will be relaunched if it was force killed: by using location services. Unfortunately this does not apply to you.

此外,您无法检测该应用是否被用户强行杀死。请查看此 StackOverflow答案

Also, you cannot detect if the app was force killed by the user. Check this StackOverflow answer.

这篇关于杀死应用后,后台获取功能无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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