即使应用终止,如何在Swift中每小时在后台获取数据? [英] How to fetch data in background every hour in Swift even the app is terminated?

查看:115
本文介绍了即使应用终止,如何在Swift中每小时在后台获取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个提供每小时提取数据功能的应用程序.即使应用终止,它也会获取数据.如何实现此功能?

I am making an app that provides functionality to fetch data every hour. It fetches data even when the app terminates. How can I implement this functionality?

经过大量搜索后,我发现使用performFetchWithCompletionHandler进行后台抓取.即使我的应用终止,此功能也能正常工作吗?我的意思是,如果我的应用处于关闭或终止状态,我可以自动调用此功能吗?

After a lot searching I found background fetching using performFetchWithCompletionHandler. Will this function work even if my app terminates? What I mean is if my app is in closed or terminated state, can I call this function automatically?

推荐答案

如果您的应用处于终止状态,您将无法执行任何操作. Apple不允许在终止或关闭状态下进行任何操作(接收通知除外).

You can't do anything if your app is in terminated state. Apple is not allowing anything (except receiving notification) in terminated or closed state.

您还受限制执行后台程序. 您可以在后台模式下执行特定类型的任务,例如:Location update,Music playing, VOIP, finite length task, Newsstand downloads, etc.您可以参考 Apple文档了解更多信息有关后台执行的详细信息.

You are also restricted for background execution also. You can perform specific kind of task in background mode like : Location update,Music playing, VOIP, finite length task, Newsstand downloads, etc. You can refer apple documentation for more details about background execution.

希望这会有所帮助:)

这篇关于即使应用终止,如何在Swift中每小时在后台获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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