Slight Documentation Error causes Background Operations Issue

Baines_1835-Mule_spinningA recent question on a Google group uncovered an error in Apple’s iOS documentation as well as PhoneGap documentation (which also led to unnecessary technical workarounds). The question is How does one keep background opertations running in Phonegap without X Code?

These background opertations include: location, voip, fetch, remote-notification, newsstand-content, external-accessory, bluetooth-central and bluetooth-peripheral.

Here is the Issue

In the Apple documentation in the section entitled iOS Keys then scroll down to UIApplicationExitsOnSuspend; the correct documentation involves replacing ‘run’ with suspend, as shown here:

UIApplicationExitsOnSuspend

Specifies whether the app terminates instead of suspend in the background. See UIApplicationExitsOnSuspend for details.

In the Phonegap documentation (in Events#pause scroll down to iOS Quirks), similarly, the correct Phonegap documentation replaces ‘running’ with exit, as shown here:

For apps to exit when locked under iOS 5, disable the app’s multi-tasking by setting UIApplicationExitsOnSuspend to YES.

This inconsistencies are difficult to spot UNLESS you read other sections, and read carefully. Luckily, the correct setting turns out to be just below UIApplicationExitsOnSuspend It is UIBackgroundModes. In other words, DO NOT use UIApplicationExitsOnSuspend for background operations, use UIBackgroundModes.

How to Run Background Opertations in iOS

UIBackgroundModes
Specifies that the app needs to continue running in the background. See UIBackgroundModes for details.

Following through to Apple’s documentation there are nine (9) services that CAN run in the background.

  1. audio
  2. location
  3. voip
  4. fetch
  5. remote-notification
  6. newsstand-content
  7. external-accessory
  8. bluetooth-central
  9. bluetooth-peripheral

There is more, but I wanted to get this out.

Lastly for the location background service, Apple uses the phrase – “significant change location service”. That phrase is documented in the section ”Getting the User’s Current Location”.

Caveat Emptor – There are two (2) sections with similar titles on that page.

Lastly, I want to thank my friend Oswald Campesato for help me to make this a bit clearer. Any remaining unclarity is mine.

Advertisements