Turn on the speaker programmatically during a call

I want to turn on the speaker programmatically during a call in the ios app. Is it possible and how?

+5
source share
2 answers

See the kAudioSessionSpeed_OverrideAudioRoute key and the kAudioSessionOverrideAudioRoute_Speaker property in the Apple Audio Session documentation.

+2
source

Swift 3.0

try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeVoiceChat, options: .defaultToSpeaker) try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker) try AVAudioSession.sharedInstance().setActive(true) 
+2
source

All Articles