Skip to main content
Quick Reference - Generate token and start a standalone call session:
Available via: SDK | UI Kits

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:
Auth tokens grant access to call sessions on behalf of a user. Never expose auth tokens in client-side code in production. Use a secure backend to generate and deliver tokens to your app.
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:
On SuccessgenerateToken() returns a GenerateToken object containing the session ID and JWT token:GenerateToken Object:

Start Call Session

Use the CometChatCalls.Component to render the call UI. This component requires a call token (generated in the previous step) and a CallSettings object that configures the call UI and behavior.

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 .setCallEventListener(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
Always remove call event listeners when the component unmounts using CometChatCalls.removeCallEventListener(listenerId). Failing to remove listeners can cause memory leaks and duplicate event handling.

Events

On EventonUserJoined returns a user object when a participant joins the call:User Object:
On EventonUserLeft returns a user object when a participant leaves the call:User Object:
On EventonUserListUpdated returns an array of all current participants in the call:User Array:User Object (each item in array):
On EventonAudioModesUpdated returns an array of available audio output modes:Audio Modes Array:Audio Mode Object (each item in array):
On EventonCallSwitchedToVideo is invoked when an audio call is upgraded to video. This event may not include additional data.

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. Useful for allowing users to switch their camera view without leaving the call.

Mute Audio

Controls the local audio stream transmission. When muted, other participants cannot hear the local user.
  • true — Mutes the microphone, stops transmitting audio
  • false — Unmutes the microphone, resumes audio transmission

Pause Video

Controls the local video stream transmission. When paused, other participants see a frozen frame or avatar instead of live video.
  • true — Pauses the camera, stops transmitting video
  • false — Resumes the camera, continues video transmission

Set Audio Mode

Routes the audio output to a specific device. Use this to let users choose between speaker, earpiece, or connected audio devices. Available modes:
  • CometChat.AUDIO_MODE.SPEAKER — Device speaker (loudspeaker)
  • CometChat.AUDIO_MODE.EARPIECE — Phone earpiece
  • CometChat.AUDIO_MODE.BLUETOOTH — Connected Bluetooth device
  • CometChat.AUDIO_MODE.HEADPHONES — Wired headphones

Switch To Video Call

Upgrades an ongoing audio call to a video call. This enables the camera and starts transmitting video to other participants. The remote participant receives the onCallSwitchedToVideo() callback.

Get Audio Output Modes

Returns the list of available audio output devices. Use this to display audio options to the user and then set the selected mode using setAudioMode().
On SuccessgetAudioOutputModes() returns an object containing an array of available audio modes:Response Object:Mode Object (each item in modes array):

End Call

Terminates the current call session and releases all media resources (camera, microphone, network connections). After calling this method, the call view should be closed.

Best Practices

Call tokens are session-specific and time-limited. Generate them right before starting the call session rather than caching them for extended periods. This ensures the token is fresh and reduces the chance of token expiry errors.
All participants who need to join the same call must use the same sessionId when generating their call tokens. Share this ID through your backend or signaling mechanism so both parties can join the same session.
Since standalone calling uses REST API auth tokens instead of the Chat SDK login flow, ensure tokens are generated server-side and delivered securely to the client. Never hardcode auth tokens in your app bundle.
Always remove call event listeners in your component’s cleanup function (e.g., the return function of useEffect). Orphaned listeners can cause memory leaks, duplicate event handling, and unexpected behavior when navigating between screens.
The CometChatCalls.Component should be rendered inside a View with height: '100%', width: '100%', and position: 'relative'. This ensures the call UI fills the screen correctly and overlays render in the right position.

Troubleshooting

Verify the auth token is valid and hasn’t expired. Auth tokens obtained from the REST API or Dashboard have an expiry — generate a fresh one if needed. Also confirm the sessionId is a non-empty string.
Ensure the CometChatCalls.Component is wrapped in a View with explicit dimensions (height: '100%', width: '100%'). Also confirm that both callSettings and callToken props are provided and not null or undefined.
Both participants must use the exact same sessionId when generating their call tokens. Double-check that the session ID is being shared correctly between devices.
Check that the listener is registered before the call session starts. If using addCallEventListener, ensure the listenerId is unique and hasn’t been overwritten by another registration. Also verify that the Calls SDK has been initialized via CometChatCalls.init().
Check device permissions for camera and microphone. On React Native, request CAMERA and RECORD_AUDIO permissions on Android, and add NSCameraUsageDescription and NSMicrophoneUsageDescription to Info.plist on iOS.

Next Steps

Calls SDK Setup

Install dependencies, configure permissions, and initialize the Calls SDK

Recording

Record call sessions for playback and compliance

Video View Customisation

Customize the main video container and participant tiles

Call Session

Full call session management with the Chat SDK integration