iOS 7 Bluetooth Output not working for AVAudioSessionCategoryPlayAndRecord

Viewed 3018

In my app, if iPhone is connected to Bluetooth headset, play sound with Bluetooth. Else use default speaker.

Here's my code

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil];
[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeVoiceChat error:nil];
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];

However, when I tried to use category setCategory:AVAudioSessionCategoryPlayAndRecord. Route to bluetooth device stopped working.. I don't know why. Because by right, the bluetooth option should only work for Record or PlayAndRecord category...

/* only valid with AVAudioSessionCategoryRecord and AVAudioSessionCategoryPlayAndRecord */

Addition: Can I have bluetooth for output ONLY (input still use default Mic from phone)?

UPDATE

I changed the order by calling setMode first, followed by setCategory. It works for the first time running the application (a call). When I tried to do the same action again, currentRoute still gave me output = Bluetooth but the actual output returns to default phone front speaker.

1 Answers
Related