Fixes #3136 - Stop manually configuring ElementCall's AudioSession

- CallKit decides what action to to take when pressing the hardware lock button based on where the audio is routed to. Using the speaker will make it lock the phone while using the headset will make it end the call.
- Before the introduction of CallKit we had to manually setup the AudioSession to keep the audio live in the background. This is now clashing with CallKit making it bevelie the audio is not routed to the speaker and causing the call be terminated when pressing the lock button.
This commit is contained in:
Stefan Ceriu
2024-08-08 13:54:45 +03:00
committed by Stefan Ceriu
parent f0ecc24a83
commit 81d669e5ce

View File

@@ -105,13 +105,6 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
} catch {
MXLog.error("Failed requesting start call action with error: \(error)")
}
do { // Setup the audio session even if setting up CallKit failed, ElementCall **is** running at this point
try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .videoChat, options: [])
try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
} catch {
MXLog.error("Failed setting up audio session with error: \(error)")
}
}
func tearDownCallSession() {
@@ -181,6 +174,14 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
// MARK: - CXProviderDelegate
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
MXLog.info("Call provider did activate audio session")
}
func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
MXLog.info("Call provider did deactivate audio session")
}
func providerDidReset(_ provider: CXProvider) {
MXLog.info("Call provider did reset: \(provider)")
}