Mastering iOS VoIP: PushKit, CallKit, and CTCarrier Integration Guide
Learn how to build a robust iOS VoIP application by integrating PushKit for VoIP push notifications, CallKit for native call UI, CTCarrier for carrier detection, and essential audio‑video SDK setup, complete with configuration steps, code samples, and best‑practice guidelines.
1. What is VoIP?
Voice over IP (VoIP) transmits voice as IP data packets over the Internet, enabling internet telephony, broadband phone services, and multimedia conferencing with clear audio quality and low cost.
2. Related Concepts
PushKit
Overview: Provides high‑priority VoIP push notifications that wake the app.
Use cases: Background wake‑up, immediate delivery, larger payloads.
Supported platforms: iOS 8.0+, iPadOS 8.0+, macOS 10.15+, watchOS 6.0+, Mac Catalyst 13.0+.
CallKit
Overview: Shows system call UI and coordinates VoIP calls with the OS.
Use cases: Incoming/outgoing call handling, call UI, call history.
Supported platforms: iOS 10.0+, iPadOS 10.0+, macOS 10.15+, Mac Catalyst 13.0+.
CTCarrier
Overview: Retrieves cellular carrier information.
Use cases: Detect carrier availability, country code, MCC/MNC to block VoIP in restricted regions.
3. Configuration and Usage
PushKit Setup
Register VoIP Push Notification certificate.
Configure client project (add PushKit, UserNotifications, AudioToolbox frameworks).
Code configuration.
<code>#import <PushKit/PushKit.h>
#import <UserNotifications/UserNotifications.h>
#import <AudioToolbox/AudioToolbox.h></code> <code>PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
pushRegistry.delegate = self;
pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
// Request notification authorization for iOS 10+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError *error) {}];</code>CallKit Control
Use CXProvider to register the call service and CXCallController to perform call actions. Handle incoming calls via CXProviderDelegate and outgoing calls via CXCallController transactions.
<code>CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
callUpdate.supportsGrouping = YES;
callUpdate.supportsDTMF = YES;
callUpdate.hasVideo = YES;
callUpdate.supportsHolding = YES;
[callUpdate setLocalizedCallerName:nickName];
CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:from];
callUpdate.remoteHandle = handle;
[[self shareInstance].callProvider reportNewIncomingCallWithUUID:[self shareInstance].uuid update:callUpdate completion:nil];</code>CTCarrier Usage
<code>#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [info subscriberCellularProvider];
BOOL allowVoIP = carrier.allowsVOIP;
NSString *carrierName = carrier.carrierName;
NSString *isoCode = carrier.isoCountryCode;
NSString *mcc = carrier.mobileCountryCode;
NSString *mnc = carrier.mobileNetworkCode;
NSLog(@"Carrier: %@, ISO: %@, MCC: %@, MNC: %@, VOIP allowed: %d", carrierName, isoCode, mcc, mnc, allowVoIP);
</code>4. Audio/Video SDK
Basic workflow: initialize SDK with App ID, set channel profile, configure local and remote video canvases, and handle join/leave actions.
<code>private lazy var mediaSDKEngine: MediaSDKEngineKit = MediaSDKEngineKit.sharedEngine(withAppId: "<YourAppId>", delegate: self)
mediaSDKEngine.setChannelProfile(.communication)
let canvas = MediaSDKVideoCanvas()
canvas.uid = 0
canvas.view = localVideoView
canvas.renderMode = .hidden
mediaSDKEngine.setupLocalVideo(canvas)
</code> <code>func mediaSDKEngine(_ engine: MediaSDKEngineKit, didJoinedOfUid uid: UInt, elapsed: Int) {
let remoteCanvas = MediaSDKVideoCanvas()
remoteCanvas.uid = uid
remoteCanvas.view = remoteVideoView
remoteCanvas.renderMode = .hidden
engine.setupRemoteVideo(remoteCanvas)
remoteVideoView.isHidden = false
}
</code>5. Summary
Use PushKit VoIP pushes to wake the app and handle background logic.
Integrate CallKit for native call UI and system‑level call management.
Leverage CTCarrier to detect carrier information and disable VoIP in restricted regions (e.g., China App Store).
Initialize and configure an audio/video SDK to provide media streams for CallKit interactions.
6. References
Voice Over IP (VoIP) Best Practices – Apple Developer.
CallKit Documentation – Apple Developer.
PushKit Documentation – Apple Developer.
CTCarrier Documentation – Apple Developer.
App Extension Programming Guide – Apple Developer.
Inke Technology
Official account of Inke Technology
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.