Skip to main content

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.
You can obtain the auth token using one of these REST API endpoints:
For testing or POC purposes, you can create an auth token directly from the CometChat Dashboard. Navigate to Users & Groups → Users, select a user, and click + Create Auth Token.
Store the auth token securely in your application for use when generating call tokens.

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. You can generate the token just before starting the call, or generate and store it ahead of time based on your use case. Use the generateToken() method to create a call token:

Start Call Session

Use the startSession() method to join a call session. This method requires:
  1. A call token (generated in the previous step)
  2. A CallSettings object that configures the call UI and behavior
  3. An HTML element where the call UI will be rendered

Call Settings

Configure the call experience using the following CallSettingsBuilder methods:

Call Listeners

The OngoingCallListener provides real-time callbacks for call session events, including participant changes, call state updates, and error conditions. You can register listeners in two ways:
  1. Via CallSettingsBuilder: Use .setCallListener(listener) when building call settings
  2. Via addCallEventListener: Use CometChatCalls.addCallEventListener(listenerId, listener) to add multiple listeners
Each listener requires a unique listenerId string. This ID is used to:
  • Prevent duplicate registrations — Re-registering with the same ID replaces the existing listener
  • Enable targeted removal — Remove specific listeners without affecting others

Events

End Call Session

To end the call session and release all media resources (camera, microphone, network connections), call CometChatCalls.endSession() in the onCallEndButtonPressed() callback.

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. Only supported on mobile browsers.
This method is only supported on mobile browsers. It has no effect on desktop browsers. Available since v4.2.0

Mute Audio

Controls the local audio stream transmission. true mutes, false unmutes.

Pause Video

Controls the local video stream transmission. true pauses, false resumes.

Start Screen Share

Stop Screen Share

Set Mode

Changes the call UI layout mode dynamically during the call.

Get Audio Input Devices

Get Audio Output Devices

Get Video Input Devices

Set Audio Input Device

Set Audio Output Device

Set Video Input Device

Switch To Video Call

End Call