miniature-air-74519
10/15/2025, 9:38 PMtall-airline-16756
10/15/2025, 9:38 PMtall-airline-16756
10/15/2025, 9:39 PMAVAudioSession configuration to achieve this:
1. Disable LiveKit’s Automatic Audio Session Configuration: To start, prevent LiveKit from automatically configuring the audio session by adding this early in your app lifecycle: AudioManager.shared.audioSession.isAutomaticConfigurationEnabled = false
2. Prevent Premature Audio Engine Start: Next, make sure the SDK’s internal audio engine doesn’t start automatically by using: try AudioManager.shared.setEngineAvailability(.none)
3. Configure AVAudioSession in CallKit’s didActivate Callback: Then, inside the provider(_:didActivate:) method, set the audio session category and mode specifically for voice calls: `func provider(_ provider: CXProvider, didActivate session: AVAudioSession) {
do {
try session.setCategory(.playAndRecord, mode: .voiceChat, options: [.mixWithOthers])
try AudioManager.shared.setEngineAvailability(.default)
} catch {
print("Error configuring audio session: \(error)")
}
}`This .voiceChat mode is key, as it routes audio to the built-in receiver by default.
4. Revert Engine Availability When Call Ends: Finally, in the provider(_:didDeactivate:) method, disable the engine to gracefully release audio resources: func provider(_ provider: CXProvider, didDeactivate session: AVAudioSession) {
do {
try AudioManager.shared.setEngineAvailability(.none)
} catch {
print("Error deactivating audio engine: \(error)")
}
}
If you'd like to see a complete implementation example, I highly recommend checking out the CallKit + PushKit example in the LiveKit Swift SDK example collection. It’s a great resource to help you get everything set up smoothly.
Sources: README.md