Skip to main content

Overview

The UI Kit’s core function is to extend the Chat SDK, translating the raw data and functionality provided by the underlying methods into visually appealing and easy-to-use UI components. The CometChat UI Kit has encapsulated the critical Chat SDK methods within its wrapper to efficiently manage internal eventing. This layer of abstraction simplifies interaction with the underlying CometChat SDK. You can access the methods using the CometChatUIKit class. This class provides access to all the public methods exposed by the CometChat UI Kit.

Init

As a developer, you need to invoke this method every time before you use any other methods provided by the UI Kit. The UIKitSettings is an important parameter of the init() function. It functions as a base settings object, housing properties such as appId, region, and authKey.
V6 Note: The extensions and aiFeature parameters from V5 have been removed. Extensions are built-in and handled automatically by MessageTemplateUtils. No registration is needed.

Login using Auth Key

Only the UID of a user is needed to log in. This simple authentication procedure is useful when you are creating a POC or if you are in the development phase. For production apps, we suggest you use AuthToken instead of Auth Key.

Login using Auth Token

This advanced authentication procedure does not use the Auth Key directly in your client code thus ensuring safety.
  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

Before a new user logs in, it is crucial to clean session data to avoid potential conflicts. This can be achieved by invoking the .logout() function.

Create User

You can dynamically create users on CometChat using the .createUser() function.

Base Message

Text Message

Send a text message to a single user or a group using the sendTextMessage() function.

Media Message

Send a media message (image, video, audio, file) using the sendMediaMessage() function.

Custom Message

Send a custom message using the sendCustomMessage() function.

Interactive Message

Form Message

Card Message

Scheduler Message

Custom Interactive Message

DateFormatter

By providing a custom implementation of the DateTimeFormatterCallback, you can globally configure how time and date values are displayed across all UI components.

AI Assistant Events

The UI Kit provides a UI-level event system for AI assistant interactions via CometChatAIAssistantEvents. These events mirror the SDK-level AIAssistantListener but are scoped to the UI layer for component-level reactions.

Add Listener

Remove Listener

Listener Interface

Implement CometChatAIAssistantEventsListener to receive events:
The UIKit’s CometChatMessageList automatically handles AI events internally. Use CometChatAIAssistantEvents only if you need additional custom UI reactions to AI streaming events.

UI Events — Card Actions

When a user interacts with a card button inside an AI agent response or a standalone card message, the UIKit emits a ccCardActionClicked event: