I'm integrating CallKit in a VoIP app and one of the integration points is letting CallKit activate audio session on behalf of the app.
Sadly, a lot of times there is no audio because AudioUnitInitialize returns a AVAudioSessionErrorCodeMissingEntitlement error. Sometimes it works, sometimes it doesn't.
This happens using the beta 6 (and before) in the Speakerbox example app, even with the “requires background audio” entitlement checked. Our app already had that entitlement and it is also seeing this error. Has anyone encounter this error?
Already filed a radar on this: rdar://27674736 http://www.openradar.me/27674736
There is a workaround for this problem: Instead of configuring AudioSession in perform:AnswerCallAction, as recommended in the demo of WWDC Session 230, do it in the completion handler of reportNewIncomingCall(with:update:completion:).
provider.reportNewIncomingCall(with: uuid, update: update) { error in
if error == nil {
configureAudioSession()
}
}
The problem could be a race condition, since it happens randomly and a lot more often in slower devices: on iPhone 5S the problem appears on more than 50% of the incoming calls, both in SpeakerBox and in our app.