Search code examples
iosios6avfoundation

Device plays audio in background, Simulator does not


Here's the issue:

  • When running my app on a device, audio play in the background.
  • When running my app on the simulator, the audio stop playing in background, and resumes when app is again in foreground.

I have done the following:

  • .plist background mode is audio.
  • I call code below in didFinishLaunchingWithOptions

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];
[[AVAudioSession sharedInstance] setActive:YES error:&error];

What am I missing? I checked that error is nil after both methods.


Solution

  • I'm quite sure the simulator doesn't support background audio, unfortunately. You'll have to resort to testing on real devices.