[Focus on Rongyun Global Internet Communication cloud] In 2016, Apple iOS10 released the CallKit framework, so that the third-party VoIP voice calling APP can have the same call experience as the mobile phone system — directly displayed on the lock screen, and during the call, The audio and video rights of the APP are the same as those of the carrier’s phone, and will not be interrupted by other apps. How to do that?

In 2018, Apple APP Approval center informed developers via email that Callkit is not allowed for apps in mainland China.

In addition, starting from iOS13, For security reasons, Apple requires that VoIP push must be used with the CallKit framework. Otherwise, the iOS system will kill the APP process after receiving VoIP push, just as it does not receive VoIP push.

Apple CallKit framework cannot be put on the shelves in China, so we cannot use the VoIP push function to wake up the screen APP in the background of the phone in China.

However, Apple’s CallKit is still an important way to improve the user experience for apps that are available in places where there are no restrictions.

As a global communication cloud service provider, Rongyun provides secure and reliable Internet communication cloud services for developers all over the world. Apps on overseas APP stores can integrate Apple CallKit after obtaining stable communication ability through Rongyun SDK, which can greatly improve user experience and ease of use.

This document describes how to implement an incoming call, answer call, end call, and call using the CallKit framework.

Apple CallKit effect

When an APP calls in the locked iPhone state, the full-screen Call and answer interface can be displayed through Apple CallKit just like an iOS native phone Call. VoIP APP and system Call have the same Call priority. And dial-up records, Siri recall, do not disturb mode in the address book can be well supported.

(APP Call interface under Apple CallKit framework)

(APP answering interface in the Framework of Apple CallKit)

The following figure briefly describes the relationship between native APP and third-party APP under CallKit framework. CallKit provides a unique Service in the system. When needed, native or third-party APPS request the system to display services such as incoming calls and unpulling through the API provided by CallKit. The Call Service arranges and schedules these requests in a unified manner to achieve a unified interactive response.

(The relationship between native and third-party apps under CallKit framework)

How to use Apple CallKit

Apple CallKit provides a unified VOICE call UI and apis for interaction with the UI. However, the actual call link monitoring, establishment and management still need to follow the original implementation ideas of the APP. Below, we share the interaction process between APP and CallKit in the scenario of incoming calls and unplugging.

Prepare

① Create a CXProvider, and specify Configuration, such as the APP name and icon, number of calls, and ring tones, in the CallKit display UI

② Implement CXProviderDelegate protocol to receive update status from Call Service, for example, the user clicks answer or hang up, and decides the processing action of network link; Also, the activation state of AudioSession determines the start and close time of Audio playback recording

③ Create a CXCallController so that the APP can send status updates to the Call Service, for example, when a user pulls out a phone or the other party hangs up

(4) If you need to lock the screen interface and display the incoming call interface when the APP is not started, build PushKit channel, which is similar to APNS, but the processing mode of the APP side is somewhat different.

(Preparation)

Incoming Call

① The APP foreground receives a connection request from the network Server, or the APP background receives a PushEvent from the network Push Server

② After the APP receives the connection request or Push message, it creates a CXCallUpdate object and specifies the number and other attributes of the call

③ report the created CXCallUpdate object to the iOS system using the reportNewIncomingCall WithUUID method of the CXProvider

4 After receiving a new Call request, the Call Service displays the UI of the original Call based on the current Call status

(Process for implementing incoming calls)

Answer Call

① Tap the Answer button on the call screen

② The Call Service notifies the APP through the CXProvider’s Delegate protocol performAnswerCallAction method

③ The APP sends the answering command to the peer end through the network to start the actual audio data transmission and call

(Process for implementing answering scenarios)

End Call

① Users click the Hang up button in the APP UI

② Create a CXEndCallAction object and specify the UUID attribute of the call

③ Create CXTransaction and assign Action to it

4. Through the CXCallController, Call Request Transaction to notify the Call Service of the hang-up event

⑤ The Call Service notifies the APP of the hanging up action through the CXProvider based on the current Call status

⑥ In the performEnd CallAction in the CXProviderDelegate, end the network link of the call and stop the audio recording and playing Loop

(Implementation process of hanging up scenario)

Outgoing Call

① The user initiates a removal request through APP UI, call record, and Siri

② Create CXHandle Specify the number to dial, create CXStartCallAction, and assign CXHandle to it

③ Create CXTransaction and assign the Action to it

④ Invoke request Transaction through the CXCallController to notify the Call Service of the unplugging event

⑤ After receiving a new dial-up request, the Call Service notifies the APP of the dial-up action through the CXProvider based on the current status

⑥ Open the network link of the call in perform StartCallAction in CXProviderDelegate. Set the call and connection time through the reportOutgoing CallWithUUID of CXProvider. Display the state of native call UI based on the result of link establishment (call success or failure)

(Allocate the scene implementation process)

Apple CallKit development framework, give voice or video call application developers a lot of convenience —

Allow developers to integrate the UI into the iPhone’s native phone APP;

Allow developers to build communication APP functions into the “common contact Information” and “Call History” of the phone APP, so that users can directly access these third-party functions through the native phone APP;

Users will be able to browse and respond to incoming calls directly from the notification center, and the incoming calls will be integrated into the native iOS UI.

All in all, Apple CallKit allows iOS to make a more complete digital phone with a variety of third-party voice communication software, which was originally used solely for making phone calls. For the majority of overseas developers of Rongyun service, the integration of Apple CallKit and in-app VOIP call can achieve system-level call effect, which greatly improves user experience.