如何在每1小时后调用一次功能?(斯威夫特)。应用程序终止时后台获取工作? [英] how to call function after every 1 hour?(Swift). Background fetch work when app is terminated?

查看:118
本文介绍了如何在每1小时后调用一次功能?(斯威夫特)。应用程序终止时后台获取工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作应用程序。它提供每一小时后获取数据的功能。所以,即使我的应用程序终止我怎么能调用该函数?



经过多次搜索后我发现后者通过performFetchWithCompletionHandler获取,但我想知道这个函数将起作用应用程序被终止?我的意思是如果我的应用程序处于关闭或终止状态我如何自动调用函数?

解决方案

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



您也受到后台执行的限制。
您可以在后台模式下执行特定类型的任务,例如:位置更新,音乐播放,VOIP,有限长度任务,报亭下载等。您可以参考苹果文档更多有关背景执行的详细信息。



希望这会有所帮助:)


i am making app. which providing functionality of fetch data after every one hour. so even when my app terminate how can i call that function?

after too much searching i found Background fetching by performFetchWithCompletionHandler but i want to know that this function will work if my app is terminated?what i mean is if my app is in closed or terminated state how can i call function automatically?

解决方案

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.

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.

Hope this will help :)

这篇关于如何在每1小时后调用一次功能?(斯威夫特)。应用程序终止时后台获取工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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