[Follow Global Internet Communication Cloud ] In 2016, Apple iOS10 released the CallKit framework, so that third-party VoIP-type voice call apps can have the same incoming call experience as the mobile phone system—displayed directly on the lock screen, and During the call, the audio and video permissions of the APP are the same as those of the operator's phone, and will not be interrupted by other applications. How to implement

In 2018, the Apple App Review Center notified developers via email that Callkit is not available for apps on the shelves in mainland China.

And, starting from iOS13, based on security considerations, Apple requires the CallKit framework to be used when using VoIP push, otherwise the iOS system will kill the APP process after receiving the VoIP push, just as if it did not receive the VoIP push.

Apple's CallKit framework cannot be used on the shelves in China, and we cannot use the VoIP push function in China to wake up the screened APP in the background of the mobile phone.

However, Apple's CallKit is still an important means to improve user experience for applications that are launched in areas where there are no restrictions on the shelves.

At the moment, there is a huge wave of going out to sea. As a global communication cloud service provider, Rongyun provides safe and reliable Internet communication cloud services for global developers. The APPs on the overseas application stores are integrated with Apple's CallKit after using Rongyun SDK to obtain stable communication capabilities, which can greatly improve user experience and ease of use.

This article shares the process of implementing call scenarios such as incoming call, answering, hanging up, and calling through the Apple CallKit framework.

Apple CallKit effect

When the iPhone is in the locked screen state, when the APP calls, the Apple CallKit can display the full-screen call and answer interface like iOS native phone calls. The VoIP APP and the system call have the same call priority level, and the dial records in the address book Siri arousal, do not disturb mode, etc. can be well supported.


(APP incoming call interface under Apple's CallKit framework)


(APP answering interface under Apple's CallKit framework)

The following figure briefly describes the relationship between native apps and third-party apps under the CallKit framework. CallKit provides a unique service in the system. When needed, native or third-party apps request display services such as incoming calls, unplugging, etc. from the system through the API provided by CallKit, and Call Service arranges and dispatches these requests in a unified manner. Unified interactive response.


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

How to use Apple CallKit

Apple CallKit provides a unified voice call UI and an API to interact with the UI, but the actual call link monitoring, construction, and management still need to follow the original implementation ideas of the APP. Below, we share the interaction process between APP and CallKit in scenarios such as incoming call and unplugging.

Prepare

① Create a CXProvider, specify the APP name and icon, the number of calls, and the ringtone of the call in the CallKit display UI Configuration

② Implement the CXProviderDelegate protocol to receive the updated status from the Call Service, for example, the user clicks to answer or hang up and other actions to determine the processing action of the network link; there is also the activation state of AudioSession, which determines the start and close timing of Audio playback and recording

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

④ If you need to lock the screen and display the incoming call interface when the APP is not started, you need to build a PushKit channel, which is similar to APNS, but the APP end processing method is somewhat different.


(Ready to work)

Incoming Call

① A connection request from the network server is received when the APP is in the foreground, or a PushEvent from the network Push Server is received when the APP is in the background

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

③ Report the CXCallUpdate object created above to the iOS system through the reportNewIncomingCall WithUUID method of CXProvider

④ After Call Service receives a new call request, it will display the native caller UI according to the current status


(Incoming call scenario realization process)

Answer Call

① The user clicks the answer button on the incoming call interface

② Call Service informs APP through CXProvider's Delegate protocol performAnswerCallAction method

③ The APP transmits the answering command to the peer through the network, starts the actual audio data transmission, and starts the call


(Realization process of answering scene)

End Call

① The user clicks the hang up button in the APP UI

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

③ Create CXTransaction and assign Action to it

④ Through CXCallController, call request Transaction to notify Call Service of this hang-up event

⑤ Call Service, through the current call status, through the CXProvider to notify the hangup action back to the APP

⑥ End the network link of the call in performEnd CallAction in CXProviderDelegate, and stop audio recording and playback Loop


(Hang-up scenario implementation process)

Outgoing Call

① The user initiates a pull request through the APP UI, call log, and Siri

② Create CXHandle to specify the dialed phone number, create CXStartCallAction and assign CXHandle to it

③ Create CXTransaction and assign the just Action to it

④ Call request Transaction through CXCallController, and notify Call Service of the pull-out event

⑤ After the Call Service receives a new dial-out request, according to the current status, it will notify the dial-out action back to the APP through CXProvider.

⑥ Open the network link of this call in the perform StartCallAction in CXProviderDelegate, set the call and connection time through the reportOutgoing CallWithUUID of CXProvider, and display the status of the native call UI (call success or failure) according to the result of the link establishment


(Dial-out scenario realization process)

Apple's CallKit development framework gives developers of voice or video call applications many conveniences——

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

Allows developers to build the functions of the communication APP in 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;

Allow users to browse and reply to incoming calls directly in the notification center, and the screen of the incoming call will also be integrated into the native iOS UI.

All in all, Apple's CallKit enables iOS's "phone" function, which was originally used to make telecom calls, to be combined with many third-party voice communication software to have a more complete digital phone capability. For the vast number of overseas developers of integrated cloud services, integrating Apple CallKit, in-app VOIP calls can obtain system-level call effects, which greatly improves user experience.


融云RongCloud
82 声望1.2k 粉丝

因为专注,所以专业