Quick Reference - Install and initialize in three steps:
Migrating from v3 to v4?Skip the create new app step. Your existing v3 app can be migrated to v4.Follow the steps mentioned in the Add the CometChat Dependency section below to upgrade to the latest version of v4.
Get your Application Keys
Signup for CometChat and then:- Create a new app
- Head over to the API & Auth Keys section and note the Auth Key, App ID & Region
Add the CometChat Dependency
Install the package as an NPM module:- npm
- yarn
Async-Storage
- npm
- yarn
Calling Component Configuration
For@cometchat/calls-sdk-react-native, please make sure you add the following additional dependencies & permissions.
Required Dependencies
Permissions
- Android
- iOS
Add the following permissions to your
AndroidManifest.xml:Platform-Specific Configuration
Android Configuration
Android Configuration
Go to the Also in the same file, in the
./android folder and open the project level build.gradle file. Add all repository URLs in the repositories block under the allprojects section.buildscript section in the ext block, make sure you have set minSdkVersion to 24.iOS Configuration
iOS Configuration
Please update the minimum target version in the Podfile. Go to the Open the
./ios folder and open the Podfile. In the Podfile, update the platform version to 11.0:ios/App folder and run pod install. This will create an App.xcworkspace file. Open this and run the app.Initialize CometChat
Theinit() method initializes the settings required for CometChat. The init() method takes the below parameters:
| Parameter | Description |
|---|---|
appID | Your CometChat App ID |
appSettings | An object of the AppSettings class created using the AppSettingsBuilder class. The region is mandatory. |
AppSettings class allows you to configure the following settings:
| Setting | Description |
|---|---|
| Region | The region where your app was created (mandatory). Set using setRegion() |
| Presence Subscription | Represents the subscription type for user presence (real-time online/offline status). See User Presence |
| autoEstablishSocketConnection(boolean) | When set to true, the SDK manages the web-socket connection internally. When set to false, you manage the connection manually. Default: true. See Managing Web-Socket connections manually |
| overrideAdminHost(adminHost: string) | Uses a custom admin URL instead of the default. Used for dedicated CometChat deployments |
| overrideClientHost(clientHost: string) | Uses a custom client URL instead of the default. Used for dedicated CometChat deployments |
init() before calling any other method from CometChat. We suggest you call the init() method on app startup, preferably in the App.tsx file.
- JavaScript
- TypeScript
Sample Console Output
Sample Console Output
On Success — On Failure —
console.log("Initialization completed successfully") returns:console.log("Initialization failed with error:", error) returns:Best Practices
Best Practices
- Always call
init()before any other CometChat method - Call
init()on app startup, preferably inApp.tsx - Use
autoEstablishSocketConnection(true)unless you have a specific need to manage connections manually - For dedicated deployments, use
overrideAdminHostandoverrideClientHostto point to your custom URLs
Troubleshooting
Troubleshooting
- Initialization fails: Verify your App ID and Region are correct
- Network errors: Check internet connectivity and firewall settings
- Calling not working: Verify all calling dependencies are installed and permissions are granted
- iOS build fails: Run
pod installin theiosdirectory after adding dependencies - Android build fails: Ensure
minSdkVersionis set to 24 and the CometChat Maven repository is added