From the team

Developer Blog

Product announcements, technical deep dives, and behind-the-scenes looks at what we are building for the Zoom Developer platform.


Video SDK

Add CallKit to a Zoom Video SDK app on iOS

Boon Jun Tan and Ekaansh Arora11 min read
  • iOS
  • CallKit
  • PushKit
  • SwiftUI
  • tutorial

Summary:Add native incoming calls, answer and hang-up controls, and microphone mute to a Zoom Video SDK app using CallKit and PushKit.

The SwiftUI quickstart gets you into a Zoom Video SDK (VSDK) session with audio, video, and a few buttons. Here we'll add CallKit so users can answer an incoming call from the iPhone's system UI and use its mute and hang-up controls.

The Zoom Video SDK CallKit sample project  includes a Swift script, VoIPPush.swift, that sends the incoming-call notification. There is no contact list or “call another user” button: tapping Join in the session form joins Zoom and registers an outgoing call on that device. You'll run the push script separately to make the receiving phone ring.

Call flow

Zoom VSDK handles the session and its audio/video. CallKit handles the system call UI and delivers actions such as answer, mute, and end. PushKit receives the VoIP notification that tells the app there's an incoming call; APNs delivers that notification from the sender. There are two flows:

Outgoing:
Join button → CallKit start transaction → Zoom join → Zoom onSessionJoin → report outgoing connected

Incoming:
Swift script (VoIPPush.swift) → APNs → PushKit → report incoming call → user answers → Zoom join → fulfill answer action

We'll give each call a UUID and use it for every CallKit operation on that call. The session name tells the SDK which session to join. The call manager stores the two together, along with the token and display name needed to join.

What you'll need

  • Xcode and a physical iPhone or iPad running iOS 18 or later, which is the sample's deployment target.
  • A Zoom Video SDK account and SDK Key/Secret.
  • A paid Apple Developer membership, with Push Notifications enabled for your app's identifier.
  • An APNs authentication key (.p8) for sending the test push.
  • A second Video SDK client. Two iPhones running the sample work well.

For the demo, we'll generate tokens with the JWT generator in Scripts/JWTGenerator.swift. For more details, refer to Scripts/README.md.

Set up the Xcode project

Signing and permissions

Select the app target and open Signing & Capabilities:

  1. Select your developer team and set your own Bundle Identifier.
  2. Enable Push Notifications.
  3. Under Background Modes, enable Audio, AirPlay, and Picture in Picture, Voice over IP, and Remote notifications.
  4. Refresh the provisioning profile if you added push support after creating it.

The project already supplies camera and microphone usage descriptions through its build settings. Run the app in the foreground and grant both permissions before trying a locked-phone test. If the prompts haven't appeared, join a session once, grant access, then end it.

The aps-environment entitlement comes from $(APS_ENVIRONMENT): development in Debug and production in Release. When sending pushes, use the environment of the installed, signed app:

BuildPush script setting
Development-signed build from XcodeAPNS_ENV=sandbox
TestFlight or App Store buildAPNS_ENV=prod

Where the code lives

Start with these three files:

  • AppDelegate.swift initializes Zoom, registers for VoIP pushes, and reads incoming payloads.
  • CallManager.swift owns the CallKit provider, call controller, and active call state.
  • SessionView+Extension.swift contains the Zoom view model, join logic, and SDK callbacks.

MySwiftUIVideoSDKApp.swift and SessionView.swift handle presentation. The Scripts folder contains the JWT generator and APNs sender we'll use for testing.

Register for incoming calls

Initialize Zoom when the app launches. An incoming push can arrive before there's a session screen, so SDK initialization belongs in AppDelegate, not in the view.

Keep PKPushRegistry in a stored property as well. A registry created only as a local variable won't stay alive after the launch method returns.

private var pushRegistry: PKPushRegistry?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
    let initParams = ZoomVideoSDKInitParams()
    initParams.domain = "zoom.us"
    let result = ZoomVideoSDK.sharedInstance()?.initialize(initParams)
    if result == .Errors_Success {
        print("SDK initialization succeeded")
    } else if let result {
        print("SDK initialization failed: \(result)")
    }

    let registry = PKPushRegistry(queue: .main)
    registry.delegate = self
    registry.desiredPushTypes = [.voIP]
    pushRegistry = registry
    return true
}

When PushKit calls pushRegistry(_:didUpdate:for:), the sample prints the device token as a hex string. We'll copy that value from Xcode shortly. A backend would store it against the user/device and remove it when PushKit calls the invalidation callback.

Keep call state outside the UI

CallManager.shared owns the CXProvider and CXCallController. It also holds incoming session details, pending answer actions, and the active Zoom view model. Those objects need to survive even when the session screen hasn't appeared yet.

Here's the provider setup:

private override init() {
    let config = CXProviderConfiguration()
    config.supportsVideo = true
    config.maximumCallGroups = 1
    config.maximumCallsPerCallGroup = 1
    config.supportedHandleTypes = [.generic]
    provider = CXProvider(configuration: config)
    super.init()
    provider.setDelegate(self, queue: .main)
}

This allows one call at a time. The sample's call updates also disable hold, grouping, ungrouping, and DTMF because it doesn't handle those actions. Setting supportsVideo tells iOS about the call; video rendering still happens in the app.

The delegate runs on the main queue. Keep that setting: the handlers call Zoom and update the view model, and some of them use MainActor.assumeIsolated on that basis.

Join from inside the app

When the user taps Join, joinSession() creates a call UUID and awaits CallManager.startOutgoingCall. The manager requests a CXStartCallAction, using the session name as the call's generic handle. If CallKit rejects the transaction, the app clears the call state and shows an error.

CallKit sends the start action here:

func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
    provider.reportCall(with: action.callUUID, updated: callUpdate(handle: action.handle.value))
    provider.reportOutgoingCall(with: action.callUUID, startedConnectingAt: nil)
    action.fulfill()
}

At this point we're starting the call. We haven't joined Zoom yet. After the transaction is accepted, the view model builds the session context:

ZoomVideoSDK.sharedInstance()?.delegate = self
let sessionContext = ZoomVideoSDKSessionContext()
sessionContext.token = jwtToken.isEmpty ? userInputJWT : jwtToken
sessionContext.sessionName = sessionName
sessionContext.userName = userName
let videoOption = ZoomVideoSDKVideoOptions()
videoOption.localVideoOn = true
sessionContext.videoOption = videoOption
let audioOption = ZoomVideoSDKAudioOptions()
audioOption.connect = true
audioOption.mute = !joinUnmutedAudio
sessionContext.audioOption = audioOption
if !sessionPassword.isEmpty {
    sessionContext.sessionPassword = sessionPassword
}

Then it calls joinSession(sessionContext). A non-nil session object means the join attempt was accepted. Wait for onSessionJoin() before telling CallKit the call is connected; if joining returns nil or fails asynchronously, report the call failed and clear its state.

Outgoing calls connect audio muted. Answered incoming calls set joinUnmutedAudio to true. The sample also requests video on join, subject to camera permission and availability. Test locked answering for audio; inspect video once the app is in the foreground.

Here's the callback that finishes either join path:

func onSessionJoin() {
    print("Session joined")
    if let uuid = callUUID {
        if isOutgoingCall {
            guard CallManager.shared.reportOutgoingConnected(uuid: uuid) else {
                callUUID = nil
                ZoomVideoSDK.sharedInstance()?.leaveSession(true)
                return
            }
        } else {
            guard CallManager.shared.reportIncomingConnected(uuid: uuid) else {
                callUUID = nil
                ZoomVideoSDK.sharedInstance()?.leaveSession(true)
                return
            }
        }
    }
    inSession = true
    if joinUnmutedAudio { audioOn = true }
}

For outgoing calls, reportOutgoingConnected checks the UUID, calls reportOutgoingCall(with:connectedAt:), and requests a muted system-call state. For incoming calls, it completes the saved answer action, which we'll look at next.

Receive the VoIP push

The test script sends a payload like this:

{
    "aps": { "content-available": 1 },
    "callUUID": "A30CDB1F-73F4-4E8F-9B9F-F4A8FCA6E9AA",
    "sessionName": "CallKitDemo",
    "token": "YOUR_FRESH_VIDEO_SDK_JWT",
    "userName": "Boon",
    "callerName": "Ekaansh"
}

callerName is what Boon sees on the incoming-call screen. userName is Boon's display name inside Zoom. The token's tpc claim must match sessionName exactly.

AppDelegate reads the payload and reports it to CallKit:

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
    let dict = payload.dictionaryPayload
    let payloadUUID = (dict["callUUID"] as? String).flatMap(UUID.init(uuidString:))
    let uuid = payloadUUID ?? UUID()
    let session = CallManager.PendingSession(
        id: uuid,
        token: dict["token"] as? String ?? "",
        sessionName: dict["sessionName"] as? String ?? "",
        userName: dict["userName"] as? String ?? "Me"
    )
    CallManager.shared.reportIncomingCall(uuid: uuid, session: session, callerName: dict["callerName"] as? String ?? "") {
        if payloadUUID == nil || session.token.isEmpty || session.sessionName.isEmpty {
            CallManager.shared.reportCallFailed(uuid: uuid) // nothing to join
        }
        completion()
    }
}

Inside reportIncomingCall, the manager retains the session details and calls reportNewIncomingCall(with:update:completion:). Once that report completes, it invokes the PushKit completion handler. If the UUID, token, or session name is missing, this sample reports the call and immediately ends it as failed.

Don't wait for Zoom to connect before reporting the incoming call. For the PushKit callback used here, iOS expects the required call report promptly; failing to report can terminate the app and affect later delivery. Apple's PushKit documentation  covers that requirement.

Join when the user answers

The answer handler starts the Zoom connection directly:

func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
    guard let session = incoming[action.callUUID] else { action.fail(); return }
    guard activeCallUUID == nil else {
        action.fail()
        reportCallFailed(uuid: action.callUUID)
        return
    }
    MainActor.assumeIsolated {
        let vm = SessionView.ViewModel()
        vm.jwtToken = session.token
        vm.sessionName = session.sessionName
        vm.userName = session.userName
        vm.callUUID = session.id
        vm.joinUnmutedAudio = true // answer already in-call with audio
        vm.inJWTInput = false      // no JWT prompt for an answered call
        activeCallUUID = action.callUUID
        activeViewModel = vm
        pendingSession = session   // SessionView reuses this same vm when it renders
        pendingAnswerActions[action.callUUID] = action
        Task { await vm.joinSession() }
    }
}

This is why the manager holds the view model. If joining lived in onAppear, answering from a locked phone would depend on a screen that might not render yet.

We save the CXAnswerCallAction in pendingAnswerActions. When Zoom calls onSessionJoin(), reportIncomingConnected removes and fulfills it. A failed join fails the pending action and ends the system call. The timeout handler also stops the attempt and clears the call state.

MainActor.assumeIsolated doesn't move execution to the main actor. It relies on the provider's .main delegate queue configured earlier. Don't copy it into a callback running on an arbitrary queue.

For presentation, the SwiftUI app observes pendingSession and opens SessionView(pending:). That view reuses activeViewModel, so opening the app after answering doesn't start a second join.

Connect audio and mute controls

CallKit tells the app when its audio session is activated. The sample applies Zoom's audio-session environment in that callback:

func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
    ZoomVideoSDK.sharedInstance()?.getAudioHelper()?.setSDKAudioSessionEnv()
}

setSDKAudioSessionEnv() configures the environment expected by the SDK. Its return value tells you whether it succeeded; check it when adapting this handler. See the Zoom audio-helper reference  for the method details.

Avoid activating the audio session independently from a view callback. The sample requests Zoom audio during joining and applies the SDK environment in didActivate. It doesn't include a complete deactivation or interruption handler, so test calls interrupted by another call, Bluetooth changes, and locked answering on the SDK version you're using. Apple's CallKit guide  explains the system audio lifecycle.

For mute, the in-app button requests a CXSetMutedCallAction. That lets the button and system mute control use the same handler:

func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
    guard activeCallUUID == action.callUUID,
          let audioHelper = ZoomVideoSDK.sharedInstance()?.getAudioHelper(),
          let myUser = ZoomVideoSDK.sharedInstance()?.getSession()?.getMySelf()
    else {
        action.fail()
        return
    }

    let result = action.isMuted ? audioHelper.muteAudio(myUser) : audioHelper.unmuteAudio(myUser)
    guard result == .Errors_Success else {
        print("setMuted SDK error: \(result.rawValue)")
        action.fail()
        return
    }
    MainActor.assumeIsolated { activeViewModel?.audioOn = !action.isMuted }
    action.fulfill()
}

If Zoom returns an error, fail the action. Otherwise, update the app's microphone state and fulfill it.

The SDK's audio-status callback also updates the in-app state. One part you'll need to extend is syncing SDK-originated changes back to CallKit—for example, when a host mutes this participant.

Hang up and clean up

The in-app end button requests a CXEndCallAction. Hanging up through the system UI reaches the same handler:

func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
    pendingAnswerActions.removeValue(forKey: action.callUUID)?.fail()
    if activeCallUUID == action.callUUID {
        ZoomVideoSDK.sharedInstance()?.leaveSession(true)
    }
    clearCall(uuid: action.callUUID)
    action.fulfill()
}

leaveSession(true) ends the session for everyone when the local user is the host. Use false if you want the host to leave without ending the session. Check the SDK return value and leave callback when implementing your own end behavior.

If Zoom ends the session first, onSessionLeave() reports the CallKit call ended and updates the UI. Don't request another end transaction from that callback. Newer SDKs have a leave callback with a reason; use it to report the appropriate outcome rather than treating every leave as a remote hang-up.

There are a few other paths to handle:

  • Declining removes the pending incoming details without joining Zoom.
  • Join failures fail the saved answer action, if any, and end the system call.
  • A start or answer timeout stops the associated connection attempt.
  • providerDidReset clears the manager's state and leaves Zoom.

A hang-up can arrive while joining is still in progress. Check the call UUID before applying a late callback, keep the SDK delegate alive through cleanup, and prevent another outgoing start from overwriting an active call. The sample has UUID checks, but its single-call state handling still needs work before supporting overlapping attempts.

Also, a remote participant leaving doesn't necessarily end the Zoom session. This sample removes their tile and leaves your local CallKit call running. If you're building strictly two-person calls, decide how the other person's hang-up should end your call and carry that event through your signaling service.

Try it with two devices

We'll use Ekaansh as the host and Boon as the receiver. Run the sample on both phones, or use another Video SDK client for Ekaansh. Boon needs the CallKit app on a physical device.

Create Ekaansh's token

Create Scripts/.env in the sample repository and add:

SESSION_NAME=CallKitDemo
ROLE=1
SDK_KEY=YOUR_VIDEO_SDK_KEY
SDK_SECRET=YOUR_VIDEO_SDK_SECRET

From the repository root, run:

swift Scripts/JWTGenerator.swift

The script reads .env and prints a JWT valid for about two hours.

Join as Ekaansh

In SessionView+Extension.swift, set these values. Leave jwtToken empty so the app prompts for a token:

var jwtToken = ""
var sessionName = "CallKitDemo"
var userName = "Ekaansh"

Build and run on Ekaansh's device, tap Join Session, paste the host token, and tap Join. Grant camera and microphone access, then unmute. Leave Ekaansh in CallKitDemo while you set up Boon.

Set up the APNs sender

In Apple Developer → Keys , create or select a key with Apple Push Notification service (APNs) enabled. Download its .p8 file and copy the Key ID. Apple lets you download the private key only once, so keep the file somewhere safe.

Your Team ID is in the Apple Developer account's Membership details. It identifies the team that owns the key and signs the app. It isn't the Bundle Identifier.

Add these settings to the same .env:

AUTH_KEY_PATH=/absolute/path/to/AuthKey_YOUR_KEY_ID.p8
KEY_ID=YOUR_APNS_KEY_ID
TEAM_ID=YOUR_APPLE_TEAM_ID
BUNDLE_ID=com.example.videosdk.callkit
APNS_ENV=sandbox
USER_NAME=Boon

KEY_ID must belong to the .p8 file at AUTH_KEY_PATH. BUNDLE_ID must match Boon's installed app. Don't add .voip to that value—the sender adds it for you.

Use plain values in this file: no surrounding quotes, no backslashes before spaces, and no comments after a value. For example:

# A path containing spaces is fine in this script's .env file
AUTH_KEY_PATH=/Users/Your Name/Keys/AuthKey_YOUR_KEY_ID.p8

# Use the sandbox endpoint for a development-signed build
APNS_ENV=sandbox

Those parsing rules apply to this script's .env reader, not to shell commands. If you export a path directly in Terminal, quote it as usual.

Get Boon's device token and send the call

Run Boon's app from Xcode. Grant permissions first, then leave Boon outside a session. Copy the VoIP device token from Xcode console:

VoIP device token: ...

Use this PushKit token, not an ordinary remote-notification token. Get a fresh one from the console if you reinstall or reprovision the app.

Change ROLE to 0 in .env and run JWTGenerator.swift again. Keep SESSION_NAME=CallKitDemo and the same SDK credentials. This gives Boon a participant token for Ekaansh's session.

Now send the push:

swift Scripts/VoIPPush.swift "VOIP_DEVICE_TOKEN" "CallKitDemo" "BOON_VIDEO_SDK_JWT" "Ekaansh"

The script creates a call UUID, signs the APNs request, and sends it to the app's .voip topic. It uses priority 10 and expiration 0 so an undelivered test call isn't stored for later delivery. Each run creates a new call; backend retries should preserve the identity of the original call.

If the script prints Sent (200), APNs accepted the request. Watch Boon's phone for the next steps: the incoming-call UI should show Ekaansh, answering should join CallKitDemo, and both users should be able to hear each other. Open the app to check video.

What to add beyond the demo

The script is enough to exercise incoming calls, but a calling app needs a backend. It should register device tokens, authorize callers and recipients, issue session JWTs, send the push, and exchange call events such as accepted, declined, canceled, busy, and ended.

The sample puts a JWT directly in the push to keep local testing simple. In production, leave the JWT out of the payload and have the app fetch it from your server after the user answers. The CallKit report still happens first, so the fetch doesn't delay it. Keep the SDK Secret and APNs private key on the server.

The sample source  contains the full handlers and UI.

For other session features, see the Video SDK for iOS documentation.