> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup

> Set up CometChat Calls SDK v5 for iOS with installation, app credentials, initialization, authentication, and the push dependencies needed for ringing.

> [!NOTE]
>
> **Faster Integration with UI Kits**
>
> If 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
>
> 👉 [iOS UI Kit Calling Integration](https://www.cometchat.com/docs/ui-kit/ios/calling-integration.md)
>
> Use this Calls SDK directly only if you need custom call UI or advanced control.

This guide walks you through installing the CometChat Calls SDK and initializing it in your iOS application.

## Add the CometChat Dependency

The Calls SDK 5.1 is distributed with Swift Package Manager. It needs iOS 15.1 or later.

1. In Xcode, go to **File > Add Package Dependencies**
2. Enter the repository URL: `https://github.com/cometchat/calls-sdk-ios`
3. Select **Up to Next Major Version** from `5.1.0` and add the `CometChatCallsSDK` product to your target

> [!NOTE]
>
> 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.

> [!NOTE]
>
> **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](https://www.cometchat.com/docs/calls/ios/voip-calling.md). 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 your `Info.plist`:

```xml theme={null}
<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>
```

> [!NOTE]
>
> 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.

Request camera and microphone access before starting or joining a call. When a call is answered from the Push SDK's
CallKit ring, the Push SDK asks for them after Answer (on a locked phone, once the user unlocks); a denied microphone
joins muted.

## 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**:

1. Select your target in Xcode
2. Go to **Signing & Capabilities**
3. Click **+ Capability** and add **Background Modes**
4. Enable:
   * **Audio, AirPlay, and Picture in Picture**
   * **Voice over IP** (required for ringing: without it PushKit delivers no VoIP push)

Ringing also needs the **Push Notifications** capability. PushKit and CallKit only work on a physical device.

## Declare a Window on Your AppDelegate

The Calls SDK reads `window` 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`:

```swift theme={null}
import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    // ...
}
```

> [!NOTE]
>
> The property can stay `nil`. The SDK only needs your `AppDelegate` to respond to `window`.

## 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`, `eu` or `in` |

```swift theme={null}
import CometChatCallsSDK

let appId = "APP_ID" // Replace with your App ID
let region = "REGION" // Replace with your Region ("us", "eu" or "in")

let callAppSettings = CallAppSettingsBuilder()
    .set(appID: appId)
    .set(region: 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 ?? "")")
})
```

| Parameter | Description |
| - | - |
| `callsAppSettings` | Configuration object with App ID and Region |
| `onSuccess` | Closure called on successful initialization |
| `onError` | Closure called if initialization fails |

> [!WARNING]
>
> **Initialize once, at launch.** A later initialization replaces the app ID and region but does not log the user
> out: the stored user and auth token stay, and belong to the first app. To switch to another app ID, call
> `CometChatCalls.logout` first, then initialize with the new app ID and log in again. When a VoIP push starts your
> app, the Push SDK may initialize the Calls SDK with the `appId` and `region` from its own configuration before your
> code runs; your own initialization with the same values is harmless.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.