I'm currently working with the iOS sdk and have fo...
# ask-ai
c
I'm currently working with the iOS sdk and have followed the quickstart to set up a basic PoC where users are able to join a room and publish audio/video. We're trying to get an iOS CallKit integration in place, but are encountering errors when answering the call through CallKit when the app is in the background
Copy code
Error Domain=io.livekit.swift-sdk Code=801 "Audio Engine Error(Audio engine returned error code: -3010)" UserInfo={NSLocalizedDescription=Audio Engine Error(Audio engine returned error code: -3010)}
If I answer the call with the app in the foreground everything works as intended. Is there something missing in my implementation that I need to add to get this working?
t
Thanks for reaching out, Felix. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To help you fix the Audio Engine Error (-3010) when answering calls through CallKit in the background, here are a few friendly tips you can follow: • Enable Background Modes: In Xcode, make sure you turn on both
audio
and
voip
modes under Signing & Capabilities. • Synchronize Audio Sessions: Use
RTCAudioSession.audioSessionDidActivate()
and
RTCAudioSession.audioSessionDidDeactivate()
to keep LiveKit's audio session in sync with CallKit's session. • Disable Automatic Audio Session Configuration: In the Swift SDK, set
AudioManager.shared.audioSession.isAutomaticConfigurationEnabled = false
so it doesn’t conflict with CallKit. • Configure Audio Session: Make sure to prepare and manage the audio session properly, enabling options like Bluetooth and speaker when needed. Following these steps usually does the trick! If you run into any trouble or want a hand with anything else, just let me know—I’m here to help! Sources: Docs/audio.md | Swift & iOS SDK | livekit/livekit_composite | DeepWiki | docs/index.html | src/RTCAudioSession.ts
c
I've implemented my
CXProviderDelegate
and
CXAnswerCallAction
to connect to a room using
room.connect(...)
, and enable the microphone with
room.localParticipant.setMicrophone(enabled: true)
when the user answers the call. Per the documentation, my delegate class also contains
Copy code
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
  LKRTCAudioSession.sharedInstance().audioSessionDidActivate(audioSession)
}

func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
  LKRTCAudioSession.sharedInstance().audioSessionDidDeactivate(audioSession) 
}
I've set the configuration flag in the init of my delegate as well.
Copy code
AudioManager.shared.audioSession.isAutomaticConfigurationEnabled = false
I can see that "Audio, AirPlay, Picture in Picture ..." and "Voice Over IP" is enabled in my background mode
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!