Rate this page:

Integrating Voximplant iOS SDK with CallKit

CallKit (available since iOS10) provides the ability to integrate call functionality into the iOS operating system.

This integration 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 which use audio,
  • taking into account the user’s blacklist settings, Do Not Disturb mode, Silent Mode, volume,
  • using 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.

Outgoing call integration with CallKit API

In order 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 will also need to create a similar CXStartCallAction if you are handling call creation through the standard Phone application of the Recent Calls tab or using Siri.

Preparing an outgoing call

Preparing an outgoing call

After that, you have to transfer control to the CXProviderDelegate.provider (_: perform :) method by CXStartCallAction. Now you need to:

  1. Create a VICall instance.
  2. Set the VICall.callKitUUID property from the CXStartCallAction that we process.
  3. Start a call with VICall.start and inform CallKit about the start of the call using the reportOutgoingCall (with: startedConnectingAt :) method.
Making an outgoing call

Making an outgoing call

When the call is established, the VICallDelegate.call (_: didConnectWithHeaders :) method will be called. In the handler of this event, it is necessary to inform CallKit about the call status change for the corresponding system UI update.

Informing about the call status change

Informing about the call status change

  1. If you need to update the call information, create a CXCallUpdate object and use the CXProvider.reportCall method.
Updating the call information

Updating the call information

Incoming call integration with CallKit API

In this article, we don't 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:

  1. Extract callKit UUID of the incoming call from the VICall instance.
  2. Retrieve the information about the caller from the VICall instance.
  3. Create a CXCallUpdate object and report on the new incoming call to the iOS call subsystem via the CallKit API.
Reporting on a new incoming call

Reporting on a new incoming call

The process of receiving an audio call will look like this:

Answering the call

Answering the call

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.

Hold handling

Hold handling

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 to interrupt 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:

Configuring the audio session

Configuring the audio session

Inform the Voximplant iOS SDK about changing the audio session status by means of the callkitstartaudio and callkitstopaudio methods of the VIAudioManager:

Informing about the audio session status change

Informing about the audio session status change