Adding BackgroundModes to your Titanium Project

Since the introduction of iOS 4 Apple has supported background services for the below listed specific tasks.

  • Audio – The application plays audible content to the user while in the background.
  • Location – The application keeps users informed of their location, even while running in the background.
  • VOIP – The application provides the ability for the user to make phone calls using an Internet connection.

Titanium has always supported these through the use of a custom plist.  In recent versions of Titanium allow you to manage this directly within your project’s tiapp.xml file.

To use this, simply add the backgroundModes node to your iphone configuration section.  After adding this configuration block, clean your Titanium project and run your project again.  Titanium will automatically create a new info.plist with your new backgroundModes.

 

backgroundModes

Something to consider

Please remember that Apple has very specific guidelines around these configuration options and will perform specific tests during the approval process if your info.plist has any backgroundModes keys. 

For example, if you have the audio key but do not use this feature correctly you will receive the below rejection notice for Apple.

While your app has declared support for audio in the UIBackgroundModes key in your Info.plist, no audio is played when users switch to another application. The audio background mode is meant for applications with audio streams, like radio applications. You’ll need to provide audible content to the user while the app is in the background or remove the “audio” setting from the UIBackgroundModes key.

For more details please see the Apple documentation here.

If you are interested in the Titanium implementation details, please read this Jira ticket.

Leave a comment