UNDERSTANDING BACKGROUND EXECUTION ON THE IOS

While iOS supports background code execution, you need to understand several things before you write your application:

  • In order to support background code execution, all applications must be compiled against the latest iOS SDK. In other words, if you have downloaded an application from the App Store that is compiled using an older SDK (prior to 4.0), the application will still terminate when you press the Home button on your iOS 5 device.
  • Background code execution is limited to three specific types of applications:
    • Audio — Playing music in the background
    • Location — Getting location data in the background
    • Voice Over IP (VOIP) — Making phone calls through an Internet connection
  • If an application does not meet any of the preceding three criteria, it will be suspended when the Home button is pressed.
  • When an application switches to the background (regardless of whether it is allowed to execute in the background or not), you should always disconnect all network connections (with the exception of VOIP applications). Applications that have active network connections are automatically terminated by the OS when they enter background mode. For example, if your location-based application is transmitting location data to a remote server, you should disable the transmission when the application is switched to the background. While you can continue receiving location data, transmitting it over a network is prohibited when the application is in ...

Get Beginning iOS 5 Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.