When using CallKit to hook into the LiveKit connec...
# ask-ai
m
When using CallKit to hook into the LiveKit connection, im using: LKRTCAudioSession.sharedInstance().audioSessionDidActivate(audioSession) why is it that the CallKit UI always only offers the Built-in Speaker as an audio output option and no option to use the Built-in receiver?
t
Thanks for reaching out, Nate. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thank you for sharing the details about the behavior you're experiencing. This happens because of some limitations within the iOS platform. When you use
LKRTCAudioSession.sharedInstance().audioSessionDidActivate(audioSession)
, iOS doesn’t show the built-in receiver as a selectable output. Instead, it smartly routes audio to the receiver (earpiece) automatically when it’s appropriate, unless you specifically override it to use the speaker. To help you make sure audio routes to the receiver during CallKit calls, here are some steps you can try: 1. Set the audio session mode to
voiceChat
and avoid using the
defaultToSpeaker
option:
Copy code
let rtcConfig = RTCAudioSessionConfiguration()
rtcConfig.category = AVAudioSession.Category.playAndRecord.rawValue
rtcConfig.categoryOptions = [.allowAirPlay, .allowBluetooth, .allowBluetoothA2DP]
rtcConfig.mode = AVAudioSession.Mode.voiceChat.rawValue
1. Use the
isSpeakerOutputPreferred
property to prefer the receiver over the speaker:
Copy code
AudioManager.shared.isSpeakerOutputPreferred = false
1. Manually configure the audio session within CallKit delegate methods:
Copy code
func provider(_: CXProvider, didActivate session: AVAudioSession) {
  do {
    try session.setCategory(.playAndRecord, mode: .voiceChat, options: [.mixWithOthers])
  } catch {
    // Handle error
  }
}
Following these steps should help make sure the receiver is the default audio output during your calls. If you have any questions or need more help, please don’t hesitate to reach out—I’m here to support you! Sources: README.md | callkit/README.md | docs/types/AndroidAudioTypeOptions.html