diff --git a/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift b/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift index a31cfb6e..7f059491 100644 --- a/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift +++ b/TelnyxWebRTCDemo/Extensions/ViewControllerVoIPExtension.swift @@ -97,6 +97,7 @@ extension ViewController : VoIPDelegate { case .CONNECTING: break case .RINGING: + self.setCurrentAudioOutput() break case .NEW: break @@ -106,6 +107,7 @@ extension ViewController : VoIPDelegate { if(self.isCallOutGoing()){ self.appDelegate.executeOutGoingCall() } + self.setCurrentAudioOutput() break case .DONE: self.resetCallStates() @@ -117,6 +119,12 @@ extension ViewController : VoIPDelegate { } } + func setCurrentAudioOutput(){ + if(self.isSpeakerActive){ + self.telnyxClient?.setSpeaker() + } + } + func executeCall(callUUID: UUID, completionHandler: @escaping (Call?) -> Void) { do { guard let callerName = self.settingsView.callerIdNameLabel.text, diff --git a/TelnyxWebRTCDemo/ViewController.swift b/TelnyxWebRTCDemo/ViewController.swift index 596ea144..c2f9def4 100644 --- a/TelnyxWebRTCDemo/ViewController.swift +++ b/TelnyxWebRTCDemo/ViewController.swift @@ -17,6 +17,7 @@ class ViewController: UIViewController { var userDefaults: UserDefaults = UserDefaults.init() var telnyxClient: TxClient? var incomingCall: Bool = false + var isSpeakerActive : Bool = false var loadingView: UIAlertController? @@ -245,6 +246,7 @@ extension ViewController : UICallScreenDelegate { } func onToggleSpeaker(isSpeakerActive: Bool) { + self.isSpeakerActive = isSpeakerActive if (isSpeakerActive) { self.telnyxClient?.setSpeaker() } else {