By Umair Khan Jadoon


2012-07-10 16:34:30 8 Comments

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?

3 comments

@Im_Lp 2012-07-10 17:24:29

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

@Mr.G 2014-09-22 05:08:19

But if i want to upload content , can i do it using NSURLSession ?? will the app will be rejected ??

@mr5 2016-03-19 08:19:47

Can you give the link where you get the information from? I'd like to read it in more details.

@hariszaman 2014-02-19 12:06:31

In iOS7 new multitasking APIs are introduced due to which it is possible to run background task for infinite duration. Apple encourages to use NSURLSession API which creates a background session and enqueues transfers

The new UIBackgroundModes which include "Background Fetch" and "remote-notifications" are also introduced in iOS7 which help in running background services

@kleopatra 2014-02-19 12:11:37

Note that link-only answers are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference.

@hariszaman 2014-04-30 18:33:03

ok done.Good to know

@IgniteCoders 2013-10-01 17:18:58

There's no way to do it as service except some special cases provided by ios, as https://stackoverflow.com/users/1515108/im-lp said. But you can simulate it. This post answer how to:

https://stackoverflow.com/a/19121250/2835520

I hope it's gonna help!

Related Questions

Sponsored Content

23 Answered Questions

[SOLVED] Xcode error "Could not find Developer Disk Image"

  • 2015-06-09 15:48:57
  • Nathan Kramer
  • 533630 View
  • 866 Score
  • 23 Answer
  • Tags:   ios iphone xcode

92 Answered Questions

13 Answered Questions

[SOLVED] How do I animate constraint changes?

42 Answered Questions

[SOLVED] Passing Data between View Controllers

27 Answered Questions

[SOLVED] How to change the background color of a UIButton while it's highlighted?

14 Answered Questions

[SOLVED] Xcode process launch failed: Security

14 Answered Questions

[SOLVED] How to run Node.js as a background process and never die?

7 Answered Questions

[SOLVED] How to get PID of background process?

15 Answered Questions

Sponsored Content