Skip to main content
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.
let callSession = CallSession.shared
Always check isCallSessionActive() before calling actions to ensure there’s an active call.

Actions

Mute Audio

Mutes your local microphone, stopping audio transmission to other participants.
CallSession.shared.muteAudio()

Unmute Audio

Unmutes your local microphone, resuming audio transmission.
CallSession.shared.unMuteAudio()

Set Audio Mode

Changes the audio output device during a call.
CallSession.shared.setAudioMode("SPEAKER")
CallSession.shared.setAudioMode("EARPIECE")
CallSession.shared.setAudioMode("BLUETOOTH")
CallSession.shared.setAudioMode("HEADPHONES")
ValueDescription
SPEAKERRoutes audio through device loudspeaker
EARPIECERoutes audio through phone earpiece
BLUETOOTHRoutes audio through connected Bluetooth device
HEADPHONESRoutes audio through wired headphones

Pause Video

Turns off your local camera, stopping video transmission. Other participants see your avatar.
CallSession.shared.pauseVideo()

Resume Video

Turns on your local camera, resuming video transmission.
CallSession.shared.resumeVideo()

Switch Camera

Toggles between front and back cameras without interrupting the video stream.
CallSession.shared.switchCamera()

Start Recording

Begins server-side recording of the call. All participants are notified.
CallSession.shared.startRecording()
Recording requires the feature to be enabled for your CometChat app.

Stop Recording

Stops the current recording. The recording is saved and accessible via the dashboard.
CallSession.shared.stopRecording()

Mute Participant

Mutes a specific participant’s audio. This is a moderator action.
CallSession.shared.muteParticipant(participantId: participant.pid)

Pause Participant Video

Pauses a specific participant’s video. This is a moderator action.
CallSession.shared.pauseParticipantVideo(participantId: participant.pid)

Pin Participant

Pins a participant to keep them prominently displayed regardless of who is speaking.
CallSession.shared.pinParticipant()

Unpin Participant

Removes the pin, returning to automatic speaker highlighting.
CallSession.shared.unPinParticipant()

Set Layout

Changes the call layout. Each participant can choose their own layout independently.
CallSession.shared.setLayout("TILE")
CallSession.shared.setLayout("SPOTLIGHT")
CallSession.shared.setLayout("SIDEBAR")
ValueDescription
TILEGrid layout with equally-sized tiles
SPOTLIGHTLarge view for active speaker, small tiles for others
SIDEBARMain speaker with participants in a sidebar

Enable Picture In Picture Layout

Enables PiP mode, allowing the call to continue in a floating window.
CallSession.shared.enablePictureInPictureLayout()

Disable Picture In Picture Layout

Disables PiP mode, returning to full-screen call interface.
CallSession.shared.disablePictureInPictureLayout()

Set Chat Button Unread Count

Updates the badge count on the chat button. Pass 0 to hide the badge.
CallSession.shared.setChatButtonUnreadCount(5)

Is Session Active

Returns true if a call session is active, false otherwise.
let isActive = CallSession.shared.isCallSessionActive()

Leave Session

Ends your participation and disconnects gracefully. The call continues for other participants.
CallSession.shared.leaveSession()

Raise Hand

Shows a hand-raised indicator to get attention from other participants.
CallSession.shared.raiseHand()

Lower Hand

Removes the hand-raised indicator.
CallSession.shared.lowerHand()

Hide Settings Panel

Hides the settings panel if it’s currently visible.
CallSession.shared.hideSettingsPanel()
PropertyTypeDescription
uidStringUnique identifier (CometChat user ID)
nameStringDisplay name
avatarStringURL of avatar image
pidStringParticipant ID for this call session
roleStringRole in the call
audioMutedBoolWhether audio is muted
videoPausedBoolWhether video is paused
isPinnedBoolWhether pinned in layout
isPresentingBoolWhether screen sharing
raisedHandTimestampIntTimestamp when hand was raised