This guide walks you through installing the CometChat Calls SDK and initializing it in your iOS application.
Add the CometChat Dependency
Using CocoaPods
Add the CometChat Calls SDK to your Podfile:
platform :ios, '13.0'
use_frameworks!
target 'YourApp' do
pod 'CometChatCallsSDK', '~> 5.0.0'
end
Then run:
Using Swift Package Manager
- In Xcode, go to File > Add Package Dependencies
- Enter the repository URL:
https://github.com/cometchat/cometchat-calls-sdk-ios
- Select the version and add to your target
Add Permissions
Add the required permissions to your Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required for video calls</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required for voice and video calls</string>
iOS requires you to provide a description for why your app needs camera and microphone access. These descriptions are shown to users when requesting permissions.
Enable Background Modes
For calls to continue when the app is in the background, enable the following background modes in your project’s Signing & Capabilities:
- Select your target in Xcode
- Go to Signing & Capabilities
- Click + Capability and add Background Modes
- Enable:
- Audio, AirPlay, and Picture in Picture
- Voice over IP (if using VoIP push notifications)
Initialize CometChat Calls
The init() method initializes the SDK with your app credentials. Call this method once when your application starts, typically in your AppDelegate or app entry point.
CallAppSettings
The CallAppSettings class configures the SDK initialization:
| Parameter | Type | Required | Description |
|---|
appId | String | Yes | Your CometChat App ID |
region | String | Yes | Your app region (us or eu) |
import CometChatCallsSDK
let appId = "APP_ID" // Replace with your App ID
let region = "REGION" // Replace with your Region ("us" or "eu")
let callAppSettings = CallAppSettingsBuilder()
.setAppId(appId)
.setRegion(region)
.build()
CometChatCalls(callsAppSettings: callAppSettings, onSuccess: { message in
print("CometChat Calls SDK initialized successfully")
}, onError: { error in
print("CometChat Calls SDK initialization failed: \(error?.errorDescription ?? "")")
})
@import CometChatCallsSDK;
NSString *appId = @"APP_ID"; // Replace with your App ID
NSString *region = @"REGION"; // Replace with your Region ("us" or "eu")
CallAppSettings *callAppSettings = [[[CallAppSettingsBuilder alloc] init]
setAppId:appId]
setRegion:region]
build];
[[CometChatCalls alloc] initWithCallsAppSettings:callAppSettings
onSuccess:^(NSString * message) {
NSLog(@"CometChat Calls SDK initialized successfully");
}
onError:^(CometChatCallException * error) {
NSLog(@"CometChat Calls SDK initialization failed: %@", error.errorDescription);
}];
| Parameter | Description |
|---|
callsAppSettings | Configuration object with App ID and Region |
onSuccess | Closure called on successful initialization |
onError | Closure called if initialization fails |