Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working in the Background continuously by avoiding application 10 min time limitation

I want to create a service kind of application, which works in background but the problem is in iOS application has 10 min limitation.

Is there any way by which we can run our app continuously, I had read some where that if we play a song in background then the app never terminate after 10min but I don't think apple would approve this.

Any suggestion would be helpful.

like image 602
Zoeb S Avatar asked Feb 15 '23 08:02

Zoeb S


1 Answers

From iOS Developer Library:

iOS 7 supports two new background execution modes for apps:

Apps that regularly require new content can register with the system and be woken up or launched periodically to download that content in the background. To register, include the UIBackgroundModes key with the fetch value in your app’s Info.plist file, and set the minimum time you want between fetch operations using the setMinimumBackgroundFetchInterval: method. You must also implement the application:performFetchWithCompletionHandler: method in your app delegate to perform any downloads. Apps that use push notifications to notify the user that new content is available can now use those notifications to initiate background download operations. To support this mode, include the UIBackgroundModes key with the remote-notification value in your app’s Info.plist file. Your app delegate must also implement the application:didReceiveRemoteNotification:fetchCompletionHandler: method.

First case: By setting the setMinimumBackgroundFetchInterval: to UIApplicationBackgroundFetchIntervalMinimum or any other number in seconds (inside your AppDelegate) will notify the system that your app requires to update its content even if it is on Background.

Please note. The fetch interval is the minimum not the maximum! So, your app will woken up when the system decides it. This may be once a day or multiple times a day. In my case, my app was updating approx. every 10 min until 19:00. After that time, took approx. 7 hours for the next update and 3 hours for the very next. Next day, the same (every 10 min until 19:00).

This technique is ideal if you are asking for regular updates from the internet (efficient and low battery consumptions) but NOT for things that require updates in a short period of time like Battery Level or Battery State.

Hope this helps.

iOS 7 is still in Beta version. So, everything above may change or updated until official release.

like image 73
OutOfBoundsException Avatar answered Mar 10 '23 10:03

OutOfBoundsException