> ## 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.

# Actions

> CometChat Calling SDK v5 - Actions for iOS

Use call actions to create your own custom controls or trigger call functionality dynamically based on your use case. All actions are called on the `CallSession.shared` singleton instance during an active call session.

## Get CallSession Instance

The `CallSession` is a singleton that manages the active call. All actions are accessed through this instance.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let callSession = CallSession.shared
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    CallSession *callSession = [CallSession shared];
    ```
  </Tab>
</Tabs>

<Note>
  Always check `isCallSessionActive()` before calling actions to ensure there's an active call.
</Note>

## Actions

### Mute Audio

Mutes your local microphone, stopping audio transmission to other participants.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.muteAudio()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] muteAudio];
    ```
  </Tab>
</Tabs>

### Unmute Audio

Unmutes your local microphone, resuming audio transmission.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.unmuteAudio()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] unmuteAudio];
    ```
  </Tab>
</Tabs>

### Set Audio Mode

Changes the audio output device during a call.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.setAudioMode("SPEAKER")
    CallSession.shared.setAudioMode("EARPIECE")
    CallSession.shared.setAudioMode("BLUETOOTH")
    CallSession.shared.setAudioMode("HEADPHONES")
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] setAudioMode:@"SPEAKER"];
    [[CallSession shared] setAudioMode:@"EARPIECE"];
    [[CallSession shared] setAudioMode:@"BLUETOOTH"];
    [[CallSession shared] setAudioMode:@"HEADPHONES"];
    ```
  </Tab>
</Tabs>

<Accordion title="AudioMode Values">
  | Value        | Description                                     |
  | ------------ | ----------------------------------------------- |
  | `SPEAKER`    | Routes audio through device loudspeaker         |
  | `EARPIECE`   | Routes audio through phone earpiece             |
  | `BLUETOOTH`  | Routes audio through connected Bluetooth device |
  | `HEADPHONES` | Routes audio through wired headphones           |
</Accordion>

### Pause Video

Turns off your local camera, stopping video transmission. Other participants see your avatar.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.pauseVideo()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] pauseVideo];
    ```
  </Tab>
</Tabs>

### Resume Video

Turns on your local camera, resuming video transmission.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.resumeVideo()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] resumeVideo];
    ```
  </Tab>
</Tabs>

### Switch Camera

Toggles between front and back cameras without interrupting the video stream.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.switchCamera()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] switchCamera];
    ```
  </Tab>
</Tabs>

### Start Recording

Begins server-side recording of the call. All participants are notified.

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

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] startRecording];
    ```
  </Tab>
</Tabs>

<Warning>
  Recording requires the feature to be enabled for your CometChat app.
</Warning>

### Stop Recording

Stops the current recording. The recording is saved and accessible via the dashboard.

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

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] stopRecording];
    ```
  </Tab>
</Tabs>

### Mute Participant

Mutes a specific participant's audio. This is a moderator action.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.muteParticipant(participantId: participant.pid)
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] muteParticipantWithParticipantId:participant.pid];
    ```
  </Tab>
</Tabs>

### Pause Participant Video

Pauses a specific participant's video. This is a moderator action.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.pauseParticipantVideo(participantId: participant.pid)
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] pauseParticipantVideoWithParticipantId:participant.pid];
    ```
  </Tab>
</Tabs>

### Pin Participant

Pins a participant to keep them prominently displayed regardless of who is speaking.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.pinParticipant(participantId: "PARTICIPANT_UID", type: "pin")
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] pinParticipantWithParticipantId:@"PARTICIPANT_UID" type:@"pin"];
    ```
  </Tab>
</Tabs>

### Unpin Participant

Removes the pin, returning to automatic speaker highlighting.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.unpinParticipant()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] unpinParticipant];
    ```
  </Tab>
</Tabs>

### Set Layout

Changes the call layout. Each participant can choose their own layout independently.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.setLayout("TILE")
    CallSession.shared.setLayout("SPOTLIGHT")
    CallSession.shared.setLayout("SIDEBAR")
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] setLayout:@"TILE"];
    [[CallSession shared] setLayout:@"SPOTLIGHT"];
    [[CallSession shared] setLayout:@"SIDEBAR"];
    ```
  </Tab>
</Tabs>

<Accordion title="LayoutType Values">
  | Value       | Description                                           |
  | ----------- | ----------------------------------------------------- |
  | `TILE`      | Grid layout with equally-sized tiles                  |
  | `SPOTLIGHT` | Large view for active speaker, small tiles for others |
  | `SIDEBAR`   | Main speaker with participants in a sidebar           |
</Accordion>

### Enable Picture In Picture Layout

Enables PiP mode, allowing the call to continue in a floating window.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.enablePictureInPictureLayout()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] enablePictureInPictureLayout];
    ```
  </Tab>
</Tabs>

### Disable Picture In Picture Layout

Disables PiP mode, returning to full-screen call interface.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.disablePictureInPictureLayout()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] disablePictureInPictureLayout];
    ```
  </Tab>
</Tabs>

### Set Chat Button Unread Count

Updates the badge count on the chat button. Pass 0 to hide the badge.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.setChatButtonUnreadCount(5)
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] setChatButtonUnreadCount:5];
    ```
  </Tab>
</Tabs>

### Is Session Active

Returns `true` if a call session is active, `false` otherwise.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let isActive = CallSession.shared.isCallSessionActive()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    BOOL isActive = [[CallSession shared] isCallSessionActive];
    ```
  </Tab>
</Tabs>

### Leave Session

Ends your participation and disconnects gracefully. The call continues for other participants.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.leaveSession()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] leaveSession];
    ```
  </Tab>
</Tabs>

### Raise Hand

Shows a hand-raised indicator to get attention from other participants.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.raiseHand()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] raiseHand];
    ```
  </Tab>
</Tabs>

### Lower Hand

Removes the hand-raised indicator.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.lowerHand()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] lowerHand];
    ```
  </Tab>
</Tabs>

### Hide Settings Panel

Hides the settings panel if it's currently visible.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CallSession.shared.hideSettingsPanel()
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [[CallSession shared] hideSettingsPanel];
    ```
  </Tab>
</Tabs>

<Accordion title="Participant Object Reference">
  | Property              | Type     | Description                           |
  | --------------------- | -------- | ------------------------------------- |
  | `uid`                 | `String` | Unique identifier (CometChat user ID) |
  | `name`                | `String` | Display name                          |
  | `avatar`              | `String` | URL of avatar image                   |
  | `pid`                 | `String` | Participant ID for this call session  |
  | `role`                | `String` | Role in the call                      |
  | `audioMuted`          | `Bool`   | Whether audio is muted                |
  | `videoPaused`         | `Bool`   | Whether video is paused               |
  | `isPinned`            | `Bool`   | Whether pinned in layout              |
  | `isPresenting`        | `Bool`   | Whether screen sharing                |
  | `raisedHandTimestamp` | `Int`    | Timestamp when hand was raised        |
</Accordion>
