iOS 10 Series: Creating VoIP Apps with CallKit

One of the most distinguished features to come out of Apple's last WWDC is the ability for third-party communications apps, like Skype, Viber, and WhatsApp, to tap into the system level and allow users to interact with incoming calls on the same level of intimacy as regular phone calls. This is possible thanks to the new iOS 10 API, CallKit, developers who are working on VOIP apps can now integrate seamlessly into the phone UI and provide a more native and intimate experience. But what does that mean? 

Say for instance, when you are receiving calls from a WhatsApp user, previously you would receive a push notification, forcing you to unlock your phone to get into the specific app in order to answer the call. With iOS 10 and CallKit, users can now receive calls the same way a normal call would come in, answering it via the lock screen. More so, users can also manage contacts as well as look at recent calls and favorites via the phone's contacts app, blurring the boundaries between VoIP apps and the native phone app.

WhatsApp (source: Apple)

WhatsApp (source: Apple)

This has led to many of the popular VOIP apps, like Skype and Viber, as well as Facebook Messenger, to release major updates to their software and take advantage of Apple's newest Framework. But CallKit goes beyond integrating VoIP apps into its system for native call management, it has also opened up through "app extensions" the ability for apps that are capable of identifying callers and prevent unwarranted calls (call spam blocking).

Apple iOS 10: Truecaller integrates with CallKit Extension API for better spam call filtering

Apple iOS 10: Truecaller integrates with CallKit Extension API for better spam call filtering

By being able to associate a phone number with a list of phone numbers or name, this tells the operating system whether or not it should block the number. Some of the popular "call spam blocking" apps that have previously had to rely on primitive techniques to identify telemarketers and other potential call spammers, like TrueCaller, can now provide caller identification at a much deeper system level.

Why Use CallKit?

If you have a VOIP app, like Skype, as mentioned previously, you would have to rely on push notifications as the gateway for allowing users to respond to calls, forcing users to unlock the phone with their password, and then getting into the app before answering the call. This is not an ideal User Experience, and something Apple has identified this year as in need of improvement.

One of the more notable goals of Apple in its latest IOS 10 iteration is the blurring between apps, allowing users to operate via functions and needs, rather than having to determine which app to use. This is evident in the introduction of SiriKit and Proactive Suggestions, which opens up the ability for users to use Siri to trigger deep functions within apps. The same goes for CallKit; users now have the ability to use "VoiP intents" to start audio and video calls as well as search a user's call history, hold calls, and identify callers.

No longer are VoIP apps second-class citizens to traditional mobile calls.

Integrating CallKit at a more deeper system level allows all apps to benefit with the use of Siri and Bluethooth to initiate and respond to calls natively. You also get the ability to have CarPlay pick up a Skype or WhatsApp call as a native call, complete with avatar and caller identification.

CallKit-enabled apps also conform to the global phone's "do not disturb" or "blocked number" functionalities on the same level as regular calls. This simple Integration is quite powerful in terms of the benefits to the end users. Blurring your app a bit more on an OS level will ensure your users like your app even more. Now you'll see how easy it is to integrate CallKit into your app, using Apple's sample fictitious app, Speakerbox.

Getting Started with CallKit

Next, you'll see how CallKit works conceptually, learn its various classes and delegates, and see its call management workflow. First you'll set up the ability to receive an incoming call and then to make an outbound call.

Architecture Overview

Apple's CallKit is a distinct collection of core services comprised of Bluetooth, CarPlay, phone calls, and Siri that operates in iOS 10. It has an interface in both the core services, in this case the test app, Speakerbox, and both of these services communicate directly to the system.

Overview of CallKit (source: Apple)

Overview of CallKit (source: Apple)

CallKit uses two prominent classes: the CXProvider API class, which manages the VoIP lifecyle and remote VoIP notifications and calls rather than any internal actions, and CXCallController, which notifies the system of local actions done by the user, such as starting a call, putting a call on hold, or ending a call.

CXProvider API uses CXCallUpdate to communicate to the system, and listens for any system action back, via CXAction, to say when an incoming call is coming into our app.

The two prominent classes of CallKit (source: Apple)

Overview of CallKit (source: Apple)

When the user initiates any actions that require external VoIP calls, the CXCallController class is the conduit the app would use to notify the system of user-initiates requests within the app.

Be sure to read the next Mobile article: Getting Started with Server-Side Swift Using the Vapor Web Framework