> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-ios-ui-kit-sdk-fixes.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Recording

> Guide to implementing call recording for voice and video calls using the CometChat iOS SDK.

<Info>
  **Quick Reference for AI Agents & Developers**

  * **Enable recording:** `CallSettingsBuilder().startRecordingOnCallStart(true).build()`
  * **Start recording:** `CallManager.startRecording()`
  * **Stop recording:** `CallManager.stopRecording()`
  * **Show button:** `CallSettingsBuilder().showCallRecordButton(true).build()`
  * **Related:** [Call Session](/sdk/ios/direct-calling) · [Ringing](/sdk/ios/default-calling) · [Calling Overview](/sdk/ios/calling-overview)
</Info>

This section will guide you to implement call recording feature for the voice and video calls.

## Implementation

Once you have decided to implement [Default Calling](/sdk/ios/default-calling) or [Direct Calling](/sdk/ios/direct-calling) calling and followed the steps to implement them. Just few additional listeners and methods will help you quickly implement call recording in your app.

You need to make changes in the CometChat.startCall method and add the required listeners for recording. Please make sure your callSettings is configured accordingly for [Default Calling](/sdk/ios/default-calling) or [Direct Calling](/sdk/ios/direct-calling).

A basic example of how to make changes to implement recording for a direct/default call:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let sessionID = "12345" //you can set anything
    let callView = UIView()// a UIView you want to show the calling view in
    let callToken = ""

    let callSettings = CallSettings.CallSettingsBuilder(callView: callView, sessionId:sessionID).setAudioOnlyCall(audioOnly: true).enableDefaultLayout(defaultLayout: true).build()

    CometChatCalls.startSession(callToken: callToken, callSetting: callSettings, view: callView) { success in
        print("CometChatCalls startSession success: \(success)")
    } onError: { error in
        print("CometChatCalls startSession error: \(String(describing: error?.errorDescription))")
    }
    ```
  </Tab>
</Tabs>

## Settings for call recording

The `CallSettings` class allows you to customise the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you an object of the `CallSettings` class which you can pass to the `startCall()` method to start the call.

The options available for recording of calls are:

| Setting                         | Type | Default | Description                           |
| ------------------------------- | ---- | ------- | ------------------------------------- |
| `showCallRecordButton(_:)`      | Bool | false   | Show/hide recording button in UI      |
| `startRecordingOnCallStart(_:)` | Bool | false   | Auto-start recording when call starts |

<Accordion title="Sample Payloads - Recording Settings">
  <Tabs>
    <Tab title="Show Recording Button">
      **CallSettingsBuilder Parameters:**

      | Property             | Type   | Value                  |
      | -------------------- | ------ | ---------------------- |
      | callView             | UIView | View to render call UI |
      | sessionId            | String | "session\_12345"       |
      | audioOnly            | Bool   | false                  |
      | defaultLayout        | Bool   | true                   |
      | showCallRecordButton | Bool   | true                   |
    </Tab>

    <Tab title="Auto-Start Recording">
      **CallSettingsBuilder Parameters:**

      | Property                  | Type   | Value                  |
      | ------------------------- | ------ | ---------------------- |
      | callView                  | UIView | View to render call UI |
      | sessionId                 | String | "session\_12345"       |
      | audioOnly                 | Bool   | false                  |
      | defaultLayout             | Bool   | true                   |
      | startRecordingOnCallStart | Bool   | true                   |
    </Tab>

    <Tab title="Both Settings Enabled">
      **CallSettingsBuilder Parameters:**

      | Property                  | Type   | Value                  |
      | ------------------------- | ------ | ---------------------- |
      | callView                  | UIView | View to render call UI |
      | sessionId                 | String | "session\_12345"       |
      | audioOnly                 | Bool   | false                  |
      | defaultLayout             | Bool   | true                   |
      | showCallRecordButton      | Bool   | true                   |
      | startRecordingOnCallStart | Bool   | true                   |
    </Tab>
  </Tabs>
</Accordion>

### Show Recording Button

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let callSettings = CallSettings.CallSettingsBuilder(callView: callView, sessionId: sessionID)
        .setAudioOnlyCall(audioOnly: false)
        .enableDefaultLayout(defaultLayout: true)
        .showCallRecordButton(true)
        .build()
    ```
  </Tab>
</Tabs>

### Auto-Start Recording

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let callSettings = CallSettings.CallSettingsBuilder(callView: callView, sessionId: sessionID)
        .setAudioOnlyCall(audioOnly: false)
        .enableDefaultLayout(defaultLayout: true)
        .startRecordingOnCallStart(true)
        .build()
    ```
  </Tab>
</Tabs>

### Start Recording

You can use the `startRecording()` method to start call recording manually during an active call.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallManager.startRecording()

    // Alternative using CometChatCalls directly:
    CometChatCalls.startRecording()
    ```
  </Tab>
</Tabs>

### Stop Recording

You can use the `stopRecording()` method to stop call recording.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallManager.stopRecording()

    // Alternative using CometChatCalls directly:
    CometChatCalls.stopRecording()
    ```
  </Tab>
</Tabs>

## Recording Listener

Implement `CallsEventsDelegate` to receive recording state change notifications. All participants receive the `onRecordingToggled` callback when recording starts or stops.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    extension ViewController: CallsEventsDelegate {
        func onRecordingToggled(recordingInfo: RTCRecordingInfo) {
            print("Recording state changed: \(recordingInfo)")
            // Update UI based on recording state
        }
    }
    ```
  </Tab>
</Tabs>

<Accordion title="Sample Payloads - Recording Listener">
  <Tabs>
    <Tab title="onRecordingToggled">
      **RTCRecordingInfo Object:**

      | Property    | Type     | Description                   |
      | ----------- | -------- | ----------------------------- |
      | isRecording | Bool?    | Is recording currently active |
      | startedBy   | RTCUser? | User who started recording    |

      **Triggered When:**

      | Scenario                              | Callback Received      |
      | ------------------------------------- | ---------------------- |
      | `CallManager.startRecording()` called | Yes - all participants |
      | `CallManager.stopRecording()` called  | Yes - all participants |
      | Recording button pressed in UI        | Yes - all participants |
      | Auto-start recording on call start    | Yes - all participants |
      | Call ends while recording             | Recording auto-stops   |
    </Tab>
  </Tabs>
</Accordion>
