Skip to content
Josh Habdas edited this page Nov 8, 2015 · 5 revisions

Follow the steps below to get background audio working on iOS. Note that background audio only works on devices and not the simulator.

  • Update your Info.plist file to include the audio in the UIBackgroundModes array. This is easy to do in Xcode 5:

    1. Select your project
    2. Select your project target
    3. Goto the Capabilities tab
    4. Expand the Background Modes pane
    5. Turn Background Modes on and select Audio and Airplay
  • Initialize your AudioSession somewhere near the beginning of your app. The ExampleApp does this in AppDelegate::application:didFinishLaunchingWithOptions.

NSError* error;
    
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];

In order to successfully resume audio when the app is backgrounded, add the following while initializing your app's AudioSession:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
Clone this wiki locally