UIKitSettingsBuilder
UIKitSettingsBuilder is a fluent builder for constructing the UIKitSettings object passed to CometChatUIKit.init().
| Method | Parameter | Description |
|---|---|---|
setAppId(appId) | string | Your CometChat App ID from the Dashboard |
setRegion(region) | string | App region (e.g. 'us', 'eu') |
setAuthKey(authKey) | string | Auth Key for dev/testing — use Auth Token in production |
subscribePresenceForAllUsers() | — | Subscribe to presence updates for all users |
subscribePresenceForFriends() | — | Subscribe to presence updates for friends only |
subscribePresenceForRoles(roles) | string[] | Subscribe to presence updates for users with specific roles |
setRoles(roles) | string[] | Set roles filter independently of presence subscription |
setAutoEstablishSocketConnection(autoEstablish) | boolean | Control whether the WebSocket connects automatically on init |
setAdminHost(adminHost) | string | Override the admin API host (custom/on-premise deployments) |
setClientHost(clientHost) | string | Override the client API host (custom/on-premise deployments) |
setStorageMode(storageMode) | CometChat.StorageMode | Set the storage mode for SDK data persistence |
build() | — | Returns the configured UIKitSettings instance |
Methods
All methods are accessed via theCometChatUIKit 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 ornull.
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.- 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
Ends the current user session.Create User
Takes aUser object and Auth Key, returns the created User object.
Update User
Takes aUser 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 aTextMessage object.
Media Message
Sends a media message in a 1:1 or group chat. Takes aMediaMessage 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 aCustomMessage object.