I want to enable loudspeaker programmatically during a voip call in ios app. Is it possible and how?
Swift 3.0
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeVoiceChat, options: .defaultToSpeaker)
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker)
try AVAudioSession.sharedInstance().setActive(true)
Look up the kAudioSessionProperty_OverrideAudioRoute key and the kAudioSessionOverrideAudioRoute_Speaker property in Apple's Audio Session documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With