Skip to main content
The UIKit wraps the Chat SDK methods to manage internal eventing and keep UI components synchronized. Use these wrapper methods instead of raw SDK calls.
CometChatUIKit.init() must be called before rendering any UIKit components or calling any SDK methods. Initialization must complete before login.
Auth Key is for development/testing only. In production, generate Auth Tokens on the server using the REST API and pass them to the client via loginWithAuthToken(). Never expose Auth Keys in production client code.

UIKitSettingsBuilder

UIKitSettingsBuilder is a fluent builder for constructing the UIKitSettings object passed to CometChatUIKit.init().

Methods

All methods are accessed via the CometChatUIKit class.

Init

Initializes the CometChat SDK. Must be called on app startup before any other UIKit method.
Replace APP_ID, REGION, and AUTH_KEY with values from the CometChat Dashboard. Auth Key is optional — use Auth Token for production.

Get Logged In User

Checks for an existing session in the SDK. Returns the logged-in user details or null.

Login using Auth Key

Simple authentication for development/POC. For production, use Auth Token.

Login using Auth Token

Production-safe authentication that does not expose the Auth Key in client code.
  1. Create a User via the CometChat API when the user signs up in your app.
  2. Create an Auth Token via the CometChat API for the new user and save the token in your database.
  3. Load the Auth Token in your client and pass it to the loginWithAuthToken() method.

Logout

Ends the current user session.

Create User

Takes a User object and Auth Key, returns the created User object.

Update User

Takes a User object and Auth Key, returns the updated User object.

Base Message

Text Message

Sends a text message in a 1:1 or group chat. Takes a TextMessage object.

Media Message

Sends a media message in a 1:1 or group chat. Takes a MediaMessage object.
Replace file with the actual File object.

Custom Message

Sends a custom message (neither text nor media) in a 1:1 or group chat. Takes a CustomMessage object.