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 the background. In this scenario, you might want to log the location data to a database and resend it to the remote server when the application is in the foreground again.

Programming multitasking iOS applications can be a very complex task. The following sections touch on some of the basics to get you started quickly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.186.247