Skip to main content
This guide walks you through installing the CometChat Calls SDK and initializing it in your Flutter application.

Add the CometChat Dependency

Step 1: Add Hosted Source

Add the CometChat Cloudsmith hosted source to your pubspec.yaml file:
dependencies:
  cometchat_calls_sdk:
    hosted: https://dart.cloudsmith.io/cometchat/cometchat/
    version: ^5.0.0-beta.2

Step 2: Install Dependencies

Run the following command to install the package:
flutter pub get

Add Permissions

Android

Add the required permissions to your android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
For Android 6.0 (API level 23) and above, you must request camera and microphone permissions at runtime before starting a call.

iOS

Add the following usage descriptions to your ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>This app requires camera access for video calls.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app requires microphone access for voice and video calls.</string>
iOS requires usage description strings for camera and microphone access. Without these entries, the app will crash when attempting to access the camera or microphone.

Initialize CometChat Calls

The init() method initializes the SDK with your app credentials. Call this method once when your application starts, typically in your main() function or root widget’s initState().

CallAppSettingBuilder

The CallAppSettingBuilder class configures the SDK initialization:
ParameterTypeRequiredDescription
appIdStringYesYour CometChat App ID
regionStringYesYour app region (us or eu)
import 'package:cometchat_calls_sdk/cometchat_calls_sdk.dart';

String appId = "APP_ID"; // Replace with your App ID
String region = "REGION"; // Replace with your Region ("us" or "eu")

CallAppSettings callAppSettings = (CallAppSettingBuilder()
  ..appId = appId
  ..region = region
).build();

CometChatCalls.init(
  callAppSettings,
  onSuccess: (String message) {
    debugPrint("CometChat Calls SDK initialized successfully");
  },
  onError: (CometChatCallsException e) {
    debugPrint("CometChat Calls SDK initialization failed: ${e.message}");
  },
);
ParameterDescription
callAppSettingsConfiguration object with App ID and Region
onSuccessCallback invoked when initialization succeeds
onErrorCallback invoked when initialization fails

Check Initialization Status

You can verify if the SDK has been initialized using the isInitialized getter:
if (CometChatCalls.isInitialized) {
  // SDK is ready to use
} else {
  // Initialize the SDK first
}