How to start the process 30 seconds in the background every hour (application for iphone)

I have an iphone application that has a 30 second process that performs some network I / O. Basically, when the application is in the background, I want this process to start every hour (actually once a day, but if it does not work, I want it to start again after a few hours).

With ios 4 background features is this possible? If so, how? What are the limitations that I have encountered?

Many thanks!

+5
source share
3 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 several different ways to get closer to your tasks. The only applications that can have completely background processes are the audio, voip, and location applications, and this needs to be declared in Info.plist.

If your application is not of this type, it will probably be difficult for you to do what you want easily. There are methods that allow you to keep your application in the background for a limited period of time (also via this link), but ultimately your application will be disconnected.

Local notifications will prompt the user to open the application - do you really want a warning message to appear on the phone every 30 seconds?

+6
source

I did some kind of research like this, look at this SO answer if you weren’t able to find it before. Applications like DataMan or Data Usage should have some kind of periodic code execution in the background, so I'm not 100% sure that what you are asking for is impossible.

+1
source

I believe using local notifications will help ... check the following ....

  • An application can create and schedule a local notification, and then the operating system transmits it according to the date and time of the schedule. If it delivers it when the application is inactive in the foreground, it displays a warning, application icon icons or plays a sound - all that is specified in the UILocalNotification object. If the application runs in the foreground, there are no warnings, icons or sound; instead, the application: didReceiveLocalNotification: method is called if the delegate implements it.

  • The delegate can check the properties of the notification and, if the notification includes user data in his user information dictionary, he can access this data and process it accordingly. On the other hand, if the local notification only marks the application icon, and the user starts the application in response, the: doneFinishLaunchingWithOptions: method is called, but the UILocalNotification object is not included in the parameter dictionary.

0
source

All Articles