如何在后台运行了〜30秒的过程每隔一小时(iPhone应用程序) [英] How to run a ~30sec process in the background every hour (iphone app)

查看:203
本文介绍了如何在后台运行了〜30秒的过程每隔一小时(iPhone应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有30秒过程,做一些网络IO一个iPhone应用程序。基本上,当应用程序在后台,我希望这个进程运行每隔一小时(一天居然一次,但如果失败,我想在小时的时间就重新运行)。

I have an iphone app that has a 30second process that does some network IO. Basically, while the app is in the background, i want this process to run every hour (actually once a day, but if it fails i want it to re-run in an hours time).

与iOS 4的背景特点,这可能吗?如果是这样,怎么样?是什么,我会碰到的限制?

With the background features of ios 4, is this possible? If so, how? What are the limitations that i'll come up against?

太感谢了!

推荐答案

看看苹果有关在后台运行code文档。

Take a look at Apple's documentation about running code in the background.

<一个href=\"http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html\">http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html

有接近后台运行任务的几种不同的方式。可以充分后台运行的进程的唯一的应用程序是音频,VOIP和位置的应用程序,这需要在Info.plist的声明。

There are few different ways of approaching backgrounded tasks. The only apps that can have fully backgrounded processes are "audio", "voip" and "location" apps, and this needs to be declared in the Info.plist.

如果您的应用程序是这种类型的没有,你可能会发现很难做你想要什么轻松。有哪些方法让你保持你的应用程序存活在后台的时候(也是在该链接)有限时期,但最终你的应用程序将被关闭。

If your app is not of this type, you'll probably find it difficult to do what you want easily. There are methods which allow you to keep your app alive in the background for a finite period of time (also at that link), but eventually your app will be shut down.

本地通知只会提示用户打开应用程序 - ?你真的想在手机上的弹出式警报每隔30秒

Local Notifications will only prompt the user to open the app - do you really want to have an alert pop-up on the phone every 30 seconds?

这篇关于如何在后台运行了〜30秒的过程每隔一小时(iPhone应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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