Implement video and audio calling using only the CometChat Calls SDK without the Chat SDK. Covers authentication, token generation, session management, and call controls.
Standalone Calling lets you add voice and video calls using only the CometChat Calls SDK — no Chat SDK required. This is ideal when you already have your own messaging system and just need calling, or when you want the smallest possible SDK footprint.The key difference from the regular Call Session flow is authentication: instead of using CometChat.getLoggedinUser(), you obtain auth tokens directly from the CometChat REST API.
Before you begin, ensure you have completed the Calls SDK setup.
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.
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:
TypeScript
JavaScript
const sessionId: string = "UNIQUE_SESSION_ID"; // Generate a unique session IDconst userAuthToken: string = "USER_AUTH_TOKEN"; // Obtained from REST APICometChatCalls.generateToken(sessionId, userAuthToken).then( (callToken: any) => { console.log("Call token generated:", callToken.token); // Use callToken to start the session }, (error: any) => { console.log("Token generation failed:", error); });
const sessionId = "UNIQUE_SESSION_ID"; // Generate a unique session IDconst userAuthToken = "USER_AUTH_TOKEN"; // Obtained from REST APICometChatCalls.generateToken(sessionId, userAuthToken).then( (callToken) => { console.log("Call token generated:", callToken.token); // Use callToken to start the session }, (error) => { console.log("Token generation failed:", error); });
Parameter
Description
sessionId
A unique session ID for the call. Generate this yourself or use a shared ID for participants to join the same call.
userAuthToken
The user auth token obtained from the CometChat REST API.
The Promise resolves with an object containing a token property (string) that you pass to startSession().
To end the call session and release all media resources (camera, microphone, network connections), call CometChatCalls.endSession() in the onCallEndButtonPressed() callback.
TypeScript
JavaScript
onCallEndButtonPressed: () => { CometChatCalls.endSession(); // Close the calling screen}
onCallEndButtonPressed: () => { CometChatCalls.endSession(); // Close the calling screen}
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:
Via CallSettingsBuilder: Use .setCallListener(listener) when building call settings
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 listeners when they’re no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
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.
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.
Terminates the current call session and releases all media resources (camera, microphone, network connections). After calling this method, the call view should be closed.