Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a ~30sec process in the background every hour (iphone app)

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).

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

Thanks so much!

like image 217
Chris Avatar asked Sep 03 '11 07:09

Chris


People also ask

How long iOS app can run in background?

The answer is simply 600 seconds (10 minutes), reason is provided by the article above.

Do Apple apps run in the background?

The only apps that are really running in the background are music or navigation apps. Go to Settings>General>Background App Refresh and you can see what other apps are allowed to update data in the background. iOS dynamically manages memory without any user intervention.

Should I let apps run in the background iPhone?

If you want to save battery life and prevent apps from running in the background, the place to do it is in the Background App Refresh screen. Believe it or not, removing apps from memory using the multitasking interface could actually lead to less battery life in the long run.


1 Answers

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

http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html

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.

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?

like image 192
Eoin Avatar answered Sep 29 '22 17:09

Eoin