Join a call session using one of two approaches: the quick start method with a session ID, or the advanced flow with manual token generation for more control.
Overview
The CometChat Calls SDK provides two ways to join a session:
| Approach | Best For | Complexity |
|---|
| Join with Session ID | Most use cases - simple and straightforward | Low - One method call |
| Join with Token | Custom token management, pre-generation, caching | Medium - Two-step process |
Both approaches require properly configured SessionSettings. The joinSession method returns a Widget? that you must place in your Flutter widget tree to render the call UI.
Rendering the Call UI
Unlike native platforms that use a container view, the Flutter SDK returns a Widget? from the joinSession call. You must place this widget in your Flutter widget tree to display the call interface:
The returned widget renders the full call UI including video tiles, controls, and participant views. It behaves like any other Flutter widget and can be placed inside a Scaffold, Container, or any layout widget.
Join with Session ID
The simplest way to join a session. Pass a session ID and the SDK automatically generates the token and joins the call.
| Parameter | Type | Description |
|---|
sessionId | String | Unique identifier for the call session |
sessionSettings | SessionSettings | Configuration for the session |
onSuccess | Function(Widget?) | Callback returning the call UI widget |
onError | Function(CometChatCallsException) | Callback for error handling |
All participants joining the same call must use the same session ID.
Join with Token
For scenarios requiring more control over token generation, such as pre-generating tokens, implementing custom caching strategies, or managing token lifecycle separately.
Step 1: Generate Token
Generate a call token for the session. Each token is unique to a specific session and user combination.
| Parameter | Type | Description |
|---|
sessionId | String | Unique identifier for the call session |
onSuccess | Function(CallToken) | Callback returning the generated token |
onError | Function(CometChatCallsException) | Callback for error handling |
Step 2: Join with Token
Use the generated token to join the session. This gives you control over when and how the token is used.
| Parameter | Type | Description |
|---|
callToken | CallToken | Previously generated token object |
sessionSettings | SessionSettings | Configuration for the session |
onSuccess | Function(Widget?) | Callback returning the call UI widget |
onError | Function(CometChatCallsException) | Callback for error handling |
Complete Example
Error Handling
Common errors when joining a session:
| Error Code | Description |
|---|
ERROR_COMETCHAT_CALLS_SDK_INIT | SDK not initialized - call init() first |
ERROR_AUTH_TOKEN | User not logged in or auth token invalid |
ERROR_CALL_SESSION_ID | Session ID is null or empty |
ERROR_CALL_TOKEN | Invalid or missing call token |
ERROR_JSON_EXCEPTION | Invalid session settings or response parsing error |