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 theCometChatUIKit 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. TheUIKitSettings is an important parameter of the init() function. It functions as a base settings object, housing properties such as appId, region, and authKey.
| Method | Type | Description |
|---|---|---|
| appId | String | Sets the unique ID for the app, available on dashboard |
| region | String | Sets the region for the app (‘us’ or ‘eu’ or ‘in’) |
| authKey | String | Sets the auth key for the app, available on dashboard |
| subscriptionType | String | Sets subscription type for tracking the presence of all users |
| roles | String | Sets subscription type for tracking the presence of users with specified roles |
| autoEstablishSocketConnection | Boolean | Configures if web socket connections will be established automatically on app initialization or be done manually, set to true by default |
V6 Note: TheextensionsandaiFeatureparameters from V5 have been removed. Extensions are built-in and handled automatically byMessageTemplateUtils. 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.- Create a User via the CometChat API when the user signs up in your app.
- Create an Auth Token via the CometChat API for the new user and save the token in your database.
- 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 thesendTextMessage() function.
Media Message
Send a media message (image, video, audio, file) using thesendMediaMessage() function.
Custom Message
Send a custom message using thesendCustomMessage() function.
Interactive Message
Form Message
Card Message
Scheduler Message
Custom Interactive Message
DateFormatter
By providing a custom implementation of theDateTimeFormatterCallback, you can globally configure how time and date values are displayed across all UI components.