Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running background services in iOS

I need to code an iOS app that sends data to server every 30 minutes. Can this work when the app is in the background? How reliable it can be?

like image 962
Umair Khan Jadoon Avatar asked Jul 10 '12 16:07

Umair Khan Jadoon


People also ask

What is running in background on iPhone?

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.

Can iOS app run in background?

No. Applications cannot run in the background for over 10 minutes, except for a few certain situations (VOIP, playing audio, etc.) An iOS app which plays audio will keep playing audio indefinitely in the background so long as the audio is playing.

How can we handle background operations iOS?

Use the BackgroundTasks framework to keep your app content up to date and run tasks requiring minutes to complete while your app is in the background. Longer tasks can optionally require a powered device and network connectivity. Register launch handlers for tasks when the app launches and schedule them as required.

How do I see background processes in iOS?

Just about every iOS user is probably aware of the task manager by now, which is accessed by double-clicking the Home button. The row of icons across the bottom show what apps are running in the background, and you can flip left or right to see more of them.


1 Answers

There is no way to perform tasks in the background permanently at the interval of time you are requesting. You may request specific permission via the developer connection but I must warn you that you will need a very compelling argument. I included the documentation below, maybe your request falls within one of the groupings that could run permanently. Or maybe you could use one of the long running background threads and adapt it in such a way that it fulfils the task you are attempting.

Directly from Apple's Documentation:

Implementing Long-Running Background Tasks

For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background:

  • Apps that play audible content to the user while in the background, such as a music player app
  • Apps that keep users informed of their location at all times, such as a navigation app
  • Apps that support Voice over Internet Protocol (VoIP) Newsstand apps that need to download and process new content
  • Apps that receive regular update from external accessories

Apps that implement these services must declare the services they support and use system frameworks to implement the relevant aspects of those services. Declaring the services lets the system know which services you use, but in some cases it is the system frameworks that actually prevent your application from being suspended.

~/End of Line

like image 137
Im_Lp Avatar answered Sep 21 '22 08:09

Im_Lp