I have a project in which I have to record the voice coming from bluetooth headset and play with default iPhone speaker. I have searched a lot and got this code.
<
Try out this amazing piece of code. Will work for sure
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *err = nil;
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:NULL];
[audioSession setActive:YES error:NULL];
NSString *preferredPortType = AVAudioSessionPortBluetoothHFP;
for (AVAudioSessionPortDescription *desc in audioSession.availableInputs)
{
if ([desc.portType isEqualToString: preferredPortType])
{
[audioSession setPreferredInput:desc error:nil];
}
}