iOS: CallKit
Voximplant integration with CallKit allows:
Displaying the system screen of an incoming call (also over third-party applications)
Displaying system screens of an active call or an unsuccessful call in case the phone is locked
Resolving the situation of multiple calls from various applications that also use CallKit API integration (switching between calls on hold, an incoming call when on a call)
Including call history
Raising the priority of the call session to the maximum, making the session uninterrupted by other applications that use audio
Taking into account the user’s blacklist settings, Do Not Disturb mode, Silent Mode, volume
Via a special mode when working with the connected audio devices (playing on all devices at the same time) to notify of an incoming call; the mode is inaccessible through the public API
You can try the demo right away.
Outbound call integration with CallKit API
To make an outgoing call, you need to initiate a custom action CXStartCallAction with the generated UUID and report this action to the CXCallController instance. You also need to create a similar CXStartCallAction if you are handling call creation through the standard Phone application of the Recent Calls tab or via Siri.
After that, you have to transfer control to the CXProviderDelegate.provider (_: perform :) method by CXStartCallAction. Now you need to:
- Create a VICall instance.
- Set the VICall.callKitUUID property from the CXStartCallAction that we process.
- Start a call with VICall.start and inform CallKit about the start of the call via the reportOutgoingCall (with: startedConnectingAt :) method.
When the call is established, the VICallDelegate.call (_: didConnectWithHeaders :) method is called. In the handler of this event, it is necessary to inform CallKit about the call status change for the corresponding system UI update.
- If you need to update the call information, create a CXCallUpdate object and use the CXProvider.reportCall method.
Inbound call integration with CallKit API
In this article, we do not cover the integration of CallKit and VoIP push notifications for incoming calls.
When an incoming call is received, control transfers to the delegate method VIClientCallManagerDelegate.client (_: didReceiveIncomingCall: withIncomingVideo: headers :), and the sequence of actions you should perform is as follows:
- Extract the callKit UUID of the incoming call from the VICall instance.
- Retrieve the information about the caller from the VICall instance.
- Create a CXCallUpdate object and report on the new incoming call to the iOS call subsystem via the CallKit API.
The process of receiving a voice call looks like this:
The rest manipulations
All the user actions performed through the iOS call subsystem are presented in the form of descendant classes of CXAction. If the action is successful, you need to confirm it via the action.fulfill API. If an error occurred during the execution, reject it via the action.fail API.
Changing the audio session privileges with CallKit
The privileges of a call audio session escalate and de-escalate automatically when the iOS subsystem is using the CallKit API. It is necessary to forbid some other applications from interrupting the audio session. The call audio session itself crowds out other already active audio sessions (player and Siri, for example).
To ensure that the configuration of the Voximplant iOS SDK audio session does not conflict with the iOS audio privilege enhancement subsystem, it is extremely important to notify the Voximplant iOS SDK about the start and end of the audio session via a special API.
When starting the application, configure the audio session:
Inform the Voximplant iOS SDK about changing the audio session status via the callkitstartaudio and callkitstopaudio methods of the VIAudioManager: