Quick Reference for AI Agents & Developers
- Auth token: Obtain via CometChat REST API (no Chat SDK required)
- Generate call token:
CometChatCalls.generateToken(authToken:sessionID:onSuccess:onError:) - Start session:
CometChatCalls.startSession(callToken:callSettings:onSuccess:onError:) - Use case: Apps needing calling without full chat infrastructure
- Related: Calling Setup · Call Session · Calling Overview
Overview
This section demonstrates how to implement calling functionality using only the CometChat Calls SDK, without requiring the Chat SDK. This is ideal for applications that need video/audio calling capabilities without the full chat infrastructure.Before you begin, ensure you have completed the Calls SDK setup.
User Authentication
To start a call session, you need a user auth token. Since this implementation doesn’t use the Chat SDK, you’ll need to obtain the auth token via the CometChat REST API.To understand user authentication in CometChat, see the User Auth documentation.
Option 1: Create Auth Token (REST API)
Creates a new auth token for a user. Endpoint:
Success Response:
Option 2: Get Auth Token (REST API)
Retrieves an existing auth token for a user. Endpoint:Option 3: Dashboard (Testing/POC)
For testing or POC purposes:- Go to CometChat Dashboard
- Navigate to Users & Groups → Users
- Select a user
- Click + Create Auth Token
- Copy the generated token
Generate Call Token
A call token is required for secure access to a call session. Each token is unique to a specific session and user combination, ensuring that only authorized users can join the call. Use thegenerateToken() method to create a call token:
- Swift
Success Response:
Error Response (CometChatCallException):
Start Call Session
Use thestartSession() method to join a call session. This method requires a call token and a CallSettings object.
- Swift
Success Response:
Error Response (CometChatCallException):
Call Settings Builder
Configure the call experience using the followingCallSettingsBuilder methods:
Call Listeners
TheCallsEventsDelegate protocol provides real-time callbacks for call session events.
- Swift
onCallEnded
Invoked when the call session terminates for a 1:1 call. Both participants receive this callback. Payload: None Action: Close the calling screenonSessionTimeout
Invoked when the call is auto-terminated due to inactivity (default: 180 seconds). v4.1.1+ Payload: NoneonCallEndButtonPressed
Invoked when the local user taps the end call button. Payload: None Action: CallCometChatCalls.endSession() and close screen
onUserJoined
Invoked when a remote participant joins the call. Payload (RTCUser):onUserLeft
Invoked when a remote participant leaves the call. Payload (RTCUser):onUserListChanged
Invoked whenever the participant list changes. Payload:onAudioModeChanged
Invoked when available audio devices change. Payload:onCallSwitchedToVideo
Invoked when an audio call is upgraded to video. Payload (CallSwitchRequestInfo):onUserMuted
Invoked when a participant’s mute state changes. Payload (RTCMutedUser):onRecordingToggled
Invoked when call recording starts or stops. Payload (RTCRecordingInfo):End Call Session
To end the call session and release all media resources, callCometChatCalls.endSession() in the onCallEndButtonPressed() callback.
- Swift
Resources Released:
Methods
These methods are available for performing custom actions during an active call session. Use them to build custom UI controls or implement specific behaviors based on your use case.These methods can only be called when a call session is active.
Switch Camera
Toggles between the front and rear camera during a video call.- Swift
- Objective-C
Mute Audio
Controls the local audio stream transmission.- Swift
- Objective-C
Pause Video
Controls the local video stream transmission.- Swift
- Objective-C
Set Audio Mode
Routes the audio output to a specific device.- Swift
- Objective-C
Enter PIP Mode
Enters Picture-in-Picture mode.- Swift
- Objective-C
Exit PIP Mode
Exits Picture-in-Picture mode.- Swift
- Objective-C
Switch To Video Call
Upgrades an ongoing audio call to a video call.- Swift
- Objective-C
Start Recording
Starts recording the call session.- Swift
- Objective-C
Stop Recording
Stops an ongoing call recording.- Swift
- Objective-C
End Session
Terminates the current call session and releases all media resources.- Swift
- Objective-C