tags:

views:

84

answers:

2

hi,

I am actually doing some daily checks of the app assuming the app will be closed and opened daily. It works fine for 3.1 devices. My question is how many days can a app live in background on iPhone 4.0 OS.

If it lives for a long time what are the best ways to make daily schedules to contact my backend server ?

+1  A: 

Backgrounding in iOS4 is more restrict than that. You can schedule 'task completion' but that can only run for 10 minutes. You could possibly do the 'location' background service but that would use quite a bit of power and I'm not sure if it would let you contact your server like you are talking about.

I suppose a more direct answer to your question is that it depends. When you are in the background, you need to be prepared to have you app closed at anytime. When the device runs low on memory, it will close any app that hasn't be run in a while.

Apple's Doc on Background Tasks

ACBurk
+1  A: 

Why do you say it works fine for 3.1 devices? If you want the app to update when opened from the springboard like it does in 3.1 then you want to use applicationWillEnterForeground: in your app delegate to call the right code.

If you must update periodically in the background then you can use setKeepAliveTimeout:handler: and beginBackgroundTaskWithExpirationHandler, but I don't know what the app store reviewers will think about a non-VOIP app using using it.

seano1