Initialize CometChat Calls
Theinit() method initializes the SDK with your app credentials. Call this method once when your application starts, typically in your app’s entry point or a dedicated initialization module.
Init Settings
Pass a plain settings object with your app credentials toinit():
Login
After initialization, authenticate the user using one of the login methods.Login with UID and Auth Key
Use this method during development or when you manage authentication on the client side. If you passedauthKey to init(), you can call login() with only the user UID. Otherwise, pass the Auth Key directly as login(uid, authKey).
Login with Auth Token
For production apps, generate an Auth Token on your backend server and use it to authenticate:Logout
Log out the current user when they sign out of your app:Check Login Status
Verify if a user is currently logged in:Get Logged In User
Retrieve the currently logged-in user’s details:Get User Auth Token
Retrieve the auth token of the currently logged-in user:Login Listeners
Monitor login state changes by adding a login listener:Error Handling
The SDK throws structured errors with the following properties:
Common error codes:
Related Documentation
- Setup - Install and configure the SDK
- Session Settings - Configure call settings
- Join Session - Start your first call