Skip to main content
This guide covers initializing the CometChat Calls SDK and authenticating users in your React Native application.

Initialize CometChat Calls

The init() 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 to init():

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 passed authKey to init(), you can call login() with only the user UID. Otherwise, pass the Auth Key directly as login(uid, authKey).
Never expose your Auth Key in production apps. Use Auth Tokens generated from your backend server instead.

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: