3

I'm trying to use this one also when app is on background, Tried to add that in capabilities -> background -> play audio. And also checked that the plist have this line.

But that doesn't work. What am I missing? Can I only play regular audio?

Idan
  • 9,880
  • 10
  • 47
  • 76
  • 1
    I had the same issue, check out imihaly's answer on my question: http://stackoverflow.com/questions/19183591/avspeechsynthesizer-in-background-mode/19200177 – user_lion Oct 07 '13 at 09:42
  • @nicu wrote that as an answer, Thank you! – Idan Oct 08 '13 at 09:55

1 Answers1

4
  1. Add on target's info.plist the key "Required background modes" to "App plays audio or streams audio/video using AirPlay".
  2. Configure the audio session in your AppDelegate:

    NSError *error = NULL;
    AVAudioSession *session = [AVAudioSession sharedInstance];
    [session setCategory:AVAudioSessionCategoryPlayback error:&error];
    if(error) {
        // Do some error handling
    }
    [session setActive:YES error:&error];
    if (error) {
        // Do some error handling
    }
    

    Don't forget to import AVFoundation.h

Credits to @nicu

Idan
  • 9,880
  • 10
  • 47
  • 76