Implementing Audio and Video Calls
This tutorial helps developers quickly understand and integrate the core functionalities of CallKit SDK (RC's audio and video calling capability library). CallKit is an audio/video calling SDK built upon CallLib, featuring default call interfaces for one-to-one and multi-party scenarios. You can rapidly implement calling features by integrating it. We also provide open-source code for this module (GitHub · Gitee), allowing customization based on your business needs.
- Considering mobile device bandwidth (especially with multi-stream video) and UI interaction, we recommend limiting video calls to 16 participants and audio-only calls to 32 participants per session. Exceeding these limits may degrade call quality.
- CallKit enforces default limits: up to 7 participants for video calls and 20 for audio calls. Adjustments can be made in the open-source code (modify
RCCall's maxMultiVideoCallUserNumber and maxMultiAudioCallUserNumber), but we advise staying within recommended thresholds.
Environment Requirements
- Xcode 11 or later.
- iOS 9.0 or later for Apple devices.
- Physical devices are required for testing audio/video features.
- CocoaPods 1.10.0 or later if using CocoaPods integration (CallKit SDK 5.1.1+ uses XCFramework, fully supported from CocoaPods 1.10.0).
For CocoaPods setup, refer to Installing CocoaPods.
Prerequisites
-
Register a developer account on the RC Console. Upon registration, a development environment app is automatically created.
-
Obtain your App Key from the console's Basic Info page. This page also displays your App Secret and data center location.
tipEach app has two distinct App Keys for development and production environments, with isolated data. Before launch, switch to the production App Key for full testing.
Service Activation
Audio/video services are disabled by default for new RC apps. You must enable them via the console before using any RC audio/video features.
- Configuration changes (activation/deactivation) take effect within 15 minutes.
- Client-side updates may take up to 2 hours. Reinstalling the app forces immediate configuration refresh.
SDK Integration
RC supports two integration methods: CocoaPods remote dependency or local XCFramework import. Below demonstrates CocoaPods.
-
If your project lacks a
Podfile, runpod initin the project root to generate one. Add this line to thePodfile:pod 'RongCloudRTC/RongCallKit', '~> x.y.z'tip- CallKit auto-downloads compatible IMKit versions (no manual specification needed). Note: From 5.2.0 to 5.4.4 (exclusive), CallKit and IMKit/IMLib must share identical version numbers (first three digits). Post-5.4.4, only the first two digits must match. CallKit 5.4.4 cannot pair with IMKit/IMLib versions below 5.4.4.
- Replace
x.y.zwith the latest CallKit version from RC SDK Downloads or viapod search RongCloudRTCafter runningpod repo update.
-
In the terminal, navigate to the
Podfiledirectory and execute:pod installtipIf encountering version conflicts (e.g.,
CocoaPods could not find compatible versions), runpod repo updatebeforepod install. -
Open the generated
.xcworkspacefile in Xcode.
SDK Initialization
CallKit relies on IM SDK for signaling. Initialize IM SDK using init with your App Key and RCInitOption (initialization config).
Import the IM SDK header first:
#import <RongIMKit/RongIMKit.h>
RCInitOption encapsulates areaCode (data center region), naviServer, fileServer, statisticServer, and crashMonitorEnable. See Initialization.
For Beijing Data Center (default), omit RCInitOption:
NSString *appKey = @"Your_AppKey"; // example: bos9p5rlcm2ba
RCInitOption *initOption = nil;
[[RCIM sharedRCIM] initWithAppKey:appKey option:initOption];
For global data centers, specify the areaCode:
NSString *appKey = @"Your_AppKey"; // example: bos9p5rlcm2ba
RCInitOption *initOption = [[RCInitOption alloc] init];
initOption.areaCode = RCAreaCodeSG; // Singapore Data Center
[[RCIM sharedRCIM] initWithAppKey:appKey option:initOption];
- For CallKit versions <5.4.2 (dev) or ≤5.3.8 (stable), use
initWithAppKeydirectly. See Initialization. - Ensure IM SDK initialization and connection precede CallKit delegate setup.
Connecting to IM Server
A user Token is an authentication credential tied to a user ID, serving as their unique identifier in RC. Audio/video signaling depends on IM services, requiring a valid Token for connection.
In production, obtain Tokens via your app server using IM Server API User Registration.
[[RCIM sharedRCIM] connectWithToken:@"Token_from_your_server"
dbOpened:^(RCDBErrorCode code) {
if (code != RCDBErrorCode_Success) {
// Handle database open failure
}
}
success:^(NSString *userId) {
// Handle connection success
}
error:^(RCConnectErrorCode status) {
// Handle connection failure
}];
Caller Implementation
Apps typically handle both calling and receiving logic simultaneously.
Initiating One-to-One Calls
Method Signature
- (void)startSingleCall:(NSString *)targetId mediaType:(RCCallMediaType)mediaType;
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| targetId | NSString | Yes | Recipient's user ID |
| mediaType | RCCallMediaType | Yes | Media type (audio/video) |
Example:
[[RCCall sharedRCCall] startSingleCall:@"recipientUserId" mediaType:RCCallMediaVideo];
Initiating Multi-Party Calls
Multi-party calls require a ConversationType_GROUP, where all participants share the same group ID.
Method Signature
- (void)startMultiCallViewController:(RCConversationType)conversationType
targetId:(NSString *)targetId
mediaType:(RCCallMediaType)mediaType
userIdList:(NSArray *)userIdList;
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| conversationType | RCConversationType | Yes | Conversation type |
| targetId | NSString | Yes | Group ID |
| mediaType | RCCallMediaType | Yes | Media type |
| userIdList | NSArray | Yes | Recipient user IDs |
Example:
[[RCCall sharedRCCall] startMultiCallViewController:ConversationType_GROUP
targetId:@"groupId"
mediaType:RCCallMediaVideo
userIdList:@[@"userA", @"userB", @"userC"]];
Member Selection for Calls
This method first displays a member selection UI, then initiates a multi-party call. For group calls, implement groupMemberDataSource.
Method Signature
- (void)startMultiCall:(RCConversationType)conversationType
targetId:(NSString *)targetId
mediaType:(RCCallMediaType)mediaType;
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| conversationType | RCConversationType | Yes | Conversation type |
| targetId | NSString | Yes | Group ID |
| mediaType | RCCallMediaType | Yes | Media type |
Example:
[[RCCall sharedRCCall] startMultiCall:ConversationType_GROUP
targetId:@"groupId"
mediaType:RCCallMediaVideo];
Callee Implementation
CallKit implements RCCallReceiveDelegate (incoming call handling) and RCCallSessionDelegate (call state) from RongCallLib by default. Recipients see an auto-displayed call UI—click Answer to join.
When the app is backgrounded or closed, incoming calls trigger notifications. Tapping the notification launches the app and displays the call UI after IM connection.
User Profile Display
Call UI user profiles rely on IM user info setup. See User Profile Configuration.
Customization
- Plugins: CallKit supports official or FaceUnity beauty filters (requires CallKit ≥5.4.0). See CallLib docs Beauty Filters.