在未来特定时间运行在iOS的后台任务 [英] Running a background task in iOS at a specific time in the future

查看:173
本文介绍了在未来特定时间运行在iOS的后台任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有连接一个后台任务(如切换使用位置服务)在iOS中7在特定点(如明天上午)的时间,而用户打开应用程序运行的方式,或无需不断运行后台进程?

Is there a way to wire a background task (such as toggling the use of location services) in iOS 7 to run at a specific point of time (e.g. tomorrow morning) without the user opening the app, or without having a constantly running background process?

这是我所知道的是有在需要的时候向设备发送推送通知,但没有人知道这种纯粹的任何设备上的替代品唯一的选择?

The only option that I am aware of is to have a push notification sent to the device at the desired time, but does anyone know of any purely on-device alternatives for this?

推荐答案

纯粹的任何设备上 - 不幸的是到现在 - 2014年没有这样的办法。 后台任务的执行,如果内容avaliable 出现在iOS的7,而一件好事,但它是基于推送。

所以,当应用程序被暂停它不能做 ANYTHING 来唤起直接本身。它不能previously已经安排了的NSTimer ,也不能使用类似 performSelector:afterDelay 等等等。在办法应用程序可以活跃起来是,如果用户自己做一些事情让它接受积极比如本地通知和警报POP操作了。 VOIP,声音,位置,书报摊:在后台模式很长一段时间的应用程序的执行,当一个应用程序有一个背景模式,论文模式只允许。即使有这些类型之一的应用程序,而一些限制不能执行其code - 你可以在文档中读到它。所以,很遗憾,我们不得不接受事务的这种状态。可能是一段时间以后的苹果工程师将一个真正的多任务,或者至少像上接收到本地通知后台任务执行,或者一些全球性后台任务sheduler用于安装的所有应用程序...

我尝试了一些实验用可可HTTP服务器上发送推送通知给此设备上安装我的应用程序内容avaliable 标志嵌入式服务器 - 但它是一个疯狂的解决方案,但它仍然是推为主。

any purely on-device - unfortunately till now - 2014 there is no such ways. Background task execution if content avaliable appeared in iOS 7 is rather a good thing but it is push-based.

So when the app is suspended it cannot do ANYTHING to rouse itself directly. It cannot previously have scheduled an NSTimer, it cannot make use of something like performSelector:afterDelay and so on and so forth. The ONLY way the app can become active again is if the USER HIMSELF does something to make it active e.g local notification received and an alert poped up. Execution of an app in background mode for a long time is only allowed when an app has a background mode, theses modes are: voip, audio, location, newstand. Even if it has one of these types an application cannot execute its code without some restrictions - you can read about it in the docs. So unfortunately we have to accept this status of affairs. May be some time in a future Apple engineers will make a true multitasking or at least something like background task execution on local notification received or some global background tasks sheduler for all the apps installed...

I tried some experiments with embedded server based on Cocoa HTTP server which sends push notifications to my app installed on this device with content-avaliable flag - but it is a crazy solution and nevertheless it is still push-based.

这篇关于在未来特定时间运行在iOS的后台任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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