Where you've declared a property callController
, declare another property callProvider
of type CXProvider
. Then, make object where you keep these 2 properties to conform to CXProviderDelegate
.
Implement all the necessary functions of CXProvider
delegate. When requesting a start call action, it is necessary to fulfill the action in the delegate method, like so:
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
/**
Configure the audio session, but do not start call audio here, since it must be done once
the audio session has been activated by the system after having its priority elevated.
*/
CallAudio.configureAudioSession()
action.fulfill()
}
Here is the code recap:
In your class:
private var provider: CXProvider!
private var callController: CXCallController!
Conform to CXProvider delegate:
class CallProvider: NSObject, CXProviderDelegate {
Create the CXProvider object and assign it's delegate:
provider = CXProvider(configuration: configuration)
provider.setDelegate(self, queue: nil) // 'nil' means it will run on main queue
Implement CXProvider delegate functions, example for start call action:
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {}
Cheers!