diff --git a/Linphone/UI/Call/CallView.swift b/Linphone/UI/Call/CallView.swift index 3e302e8b7..eafdae478 100644 --- a/Linphone/UI/Call/CallView.swift +++ b/Linphone/UI/Call/CallView.swift @@ -76,6 +76,12 @@ struct CallView: View { } } } + .onAppear { + callViewModel.enableAVAudioSession() + } + .onDisappear { + callViewModel.disableAVAudioSession() + } } } diff --git a/Linphone/UI/Call/ViewModel/CallViewModel.swift b/Linphone/UI/Call/ViewModel/CallViewModel.swift index 4f7aeb8f4..8e98b4914 100644 --- a/Linphone/UI/Call/ViewModel/CallViewModel.swift +++ b/Linphone/UI/Call/ViewModel/CallViewModel.swift @@ -53,12 +53,26 @@ class CallViewModel: ObservableObject { init() { do { try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .voiceChat, options: .allowBluetooth) + } catch _ { + + } + resetCallView() + } + + func enableAVAudioSession(){ + do { try AVAudioSession.sharedInstance().setActive(true) } catch _ { } - - resetCallView() + } + + func disableAVAudioSession(){ + do { + try AVAudioSession.sharedInstance().setActive(false) + } catch _ { + + } } func resetCallView() {