Callkit - No audio if starting a call from background

This started to happen since iOS 13.3.1


On my app I use Callkit + WebRTC to establish VOIP connections. I always managed to establish connections without an issue.


However, since 13.3.1 that I'm not able to start a Callkit call if the app's not on the foreground: I manage to establish the connection but the callkit isn't started (no green icon/bar on the top) and the microphone isn't picked up also.


I always get the following error:

Error requesting transaction ((
    " contactIdentifier=(null) video=0 relay=0 upgrade=0 retry=0 emergency=0 isVoicemail=0 ttyType=0 localLandscapeAspectRatio={0, 0} localPortraitAspectRatio={0, 0} dateStarted=(null) localSenderIdentityUUID=(null) shouldSuppressInCallUI=0>"
)): (Error Domain=com.apple.CallKit.error.requesttransaction Code=6 "(null)")


From what I've gathered (there is almost no information about this code 6 error) Callkit may terminate if the AudioSession isn't active. However I'm not understanding what happened since 13.3.1 to affect this on background (I have Audio,Airplay and PIP / Voice over IP / Bacgkround fetch) modes active.


In the meanwhile I tried inumerous things, from activating the session myself (both before callController.request and also before provider.reportOutgoingCall)


do {
    try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playAndRecord, mode: AVAudioSession.Mode.voiceChat, options: .mixWithOthers)
    try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker)
    try AVAudioSession.sharedInstance().setActive(true)
} catch {
    print(error)
}


to playing a silent audio (trying to force the AVAudioSession to activate) but had no luck whatsoever.


Any suggestions?

Replies

Starting outgoing calls from the background isn't something CallKit ever really intended to support and that capability has become increasingly restricted as the audio system itself has changed. If this functionality is critical to your app, then please file a DTS incident where I can talk through your specific situation in more depth:


https://developer.apple.com/support/technical/


-Kevin Elliott

DTS Engineer, CoreOS/Hardware