Faster Integration with UI KitsIf you’re using CometChat UI Kits, voice and video calling can be quickly integrated:
- Incoming & outgoing call screens
- Call buttons with one-tap calling
- Call logs with history
Add the CometChat Dependency
The Calls SDK 5.1 is distributed with Swift Package Manager. It needs iOS 15.1 or later.- In Xcode, go to File > Add Package Dependencies
- Enter the repository URL:
https://github.com/cometchat/calls-sdk-ios - Select Up to Next Major Version from
5.1.0and add theCometChatCallsSDKproduct to your target
The Calls SDK’s API is Swift only: it doesn’t ship an Objective-C interface. An Objective-C app calls it from Swift code in the same target. The Push Notifications SDK, which rings calls, supports Objective-C.
Ringing users? Incoming calls ring through the Push Notifications SDK 2.0: add its Core and Calls products
(
CometChatPushNotificationsSwift and CometChatPushNotificationsCalls) as well, and follow
Push Ringing. The Calls SDK alone can start, join and end calls, but it cannot ring a
device that is not running your app.Add Permissions
Add the required permissions to yourInfo.plist:
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. Add both strings even if your app only makes audio calls: the Calls SDK links the camera.
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 (required for ringing: without it PushKit delivers no VoIP push)
Declare a Window on Your AppDelegate
The Calls SDK readswindow from your app delegate when the device orientation changes. Xcode’s default scene-based template puts window only on the SceneDelegate, so without it the app crashes with -[AppDelegate window]: unrecognized selector sent to instance when a call starts, typically right after the camera permission prompt. Declare the property on your AppDelegate, even if you set the window up in your SceneDelegate:
The property can stay
nil. The SDK only needs your AppDelegate to respond to window.Initialize CometChat Calls
Theinit() 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
TheCallAppSettings class configures the SDK initialization: