How to make local calls with CallKit and Sendbird Calls

December 15, 2020

This tutorial guides you through the process of developing VoIP apps using the Sendbird Calls framework and Apple’s CallKit framework. You’ll start by developing a simple project that allows you to make local calls using CallKit.

Each section provides entire codes of the file. You can just copy and paste the code into the appropriate files. Provided code may not be the only correct implementations. You can customize them to suit your needs by thoroughly reviewing the following steps. These steps will help you understand more about CallKit.

You can download the complete project file here.

Estimated time

30 minutes

Section 1: The basic configuration of CallKit Step 1

To develop a VoIP app service, you need a VoIP certificate for the app. Go to the Apple Developer page and sign in.

Step 2

Go to Certificate, Identifiers & Profiles > Certificates > Create a New Certificate. You will find the VoIP Services Certificate under the Services section. Create the VoIP service certificate.

Step 3

Go to Target > Signing & Capabilities. Add Background Modes and enable Voice over IP. This will create an .entitlements file and appropriate permissions that allow you to use VoIP services. If you don’t enable Voice over IP, a CallKit error code 1 will occur.

Section 2: Design the CallKit UI

Step 1

To configure localized information for CallKit, create a file named CXProviderConfiguration.extension.swift.

CXProvider

CXProvider is an object that represents a telephony provider. CXProvider is initialized with CXProviderConfiguration. VoIP apps should only create one instance of CXProvider per app and use it globally. For more information, see Apple developer docs – CXProvider.

Each provider can specify an object conforming to the CXProviderDelegate protocol to respond to events, such as starting a call, putting a call on hold, or activating a provider’s audio session.

Step 2 extension CXProviderConfiguration { static var custom: CXProviderConfiguration { // 1 let configuration = CXProviderConfiguration(localizedName: “Homing Pigeon”) // 2 // Native call log shows video icon if it was video call. configuration.supportsVideo = true // Support generic type to handle *User ID* configuration.supportedHandleTypes = [.generic] // Icon image forwarding to app in CallKit View if let iconImage = UIImage(named: “App Icon”) { configuration.iconTemplateImageData = iconImage.pngData() } return configuration } }

A CXProviderConfiguration object controls the native call UI for incoming and outgoing calls, including the localized name of the provider, ringtone to be played for incoming calls, and the icon to be displayed during calls. For more information, see Apple developer docs – CXProviderConfiguration.

Initialize the CXProviderConfiguration object with a localized name. This name will appear in the call view when your users receive a call through CallKit. Use appropriate naming, such as your app service name, as the localized name. In this case, we used “Homing Pigeon.” Configure the user interface and its capabilities. In this step, set supportsVideo, supportedHandleTypes, and iconTemplateImageData. If you want to further customize CallKit, see the table below. You can also refer to the Apple developer document – CXProviderConfiguration. name description default value ringtoneSound The name of the sound resource in the app bundle to be used for the provider ringtone. iconTemplateImageData The PNG data for the icon image to be displayed for the provider. maximumCallGroups The maximum number of call

Continue reading

This post was originally published on this site