AI Integration Quick Reference
AI Integration Quick Reference
Retrieve Logged In User Details
UsegetLoggedInUser() to get the details of the logged-in user. Returns null if no user is logged in.
- Java
- Kotlin
User object containing all the information related to the logged-in user.
Retrieve List of Users
UseUsersRequestBuilder to configure filters, then call fetchNext() to retrieve users.
Set Limit
Set the number of users to fetch per request.- Java
- Kotlin
Set Search Keyword
Filter users by a search string.- Java
- Kotlin
Search In
Define which user property thesearchKeyword should be searched in. Works only with setSearchKeyword(). By default, searches both UID and Name.
- Java
- Kotlin
Set Status
The status based on which the users are to be fetched. The status parameter can contain one of the following values:CometChat.USER_STATUS.ONLINE- Returns the list of only online users.CometChat.USER_STATUS.OFFLINE- Returns the list of only offline users.
- Java
- Kotlin
Hide Blocked Users
Exclude users blocked by the logged-in user from the results. Default isfalse.
- Java
- Kotlin
Set Roles
Filter users by one or more roles.- Java
- Kotlin
Friends Only
Return only friends of the logged-in user when set totrue.
- Java
- Kotlin
Set Tags
Filter users by tags. Only users tagged with the specified tags are returned.- Java
- Kotlin
With Tags
Include tag data in the response when set totrue.
- Java
- Kotlin
Set UIDs
Fetch specific users by their UIDs. Maximum 25 UIDs per request.- Java
- Kotlin
Sort By
Sort the user list by a specific property. Default sort order isstatus => name => UID.
- Java
- Kotlin
Sort By Order
Sort the user list in ascending or descending order. Default is ascending.- Java
- Kotlin
Fetch Users
After configuring the builder, callbuild() then fetchNext() to retrieve users. Call fetchNext() repeatedly on the same object to paginate.
- Java
- Kotlin
Retrieve Particular User Details
UsegetUser() to fetch details for a specific user by UID.
- Java
- Kotlin
getUser() method takes the following parameters:
| Parameter | Description |
|---|---|
UID | The UID of the user for whom the details are to be fetched |
User object containing the details of the user is returned.
Get Online User Count
UsegetOnlineUserCount() to get the total count of online users for your app.
- Java
- Kotlin
User Payload Structure
User Object
User Object
The
Sample User Object:
User object returned by SDK methods contains the following fields:| Parameter | Type | Description |
|---|---|---|
uid | String | Unique identifier of the user |
name | String | Display name of the user |
avatar | String | URL to user’s profile picture |
link | String | URL to user’s profile page |
role | String | User role for role-based access control |
metadata | JSONObject | Custom data set by developer. Can contain any key-value pairs |
status | String | User online status. Values: "online", "offline" |
statusMessage | String | Custom status message set by user |
lastActiveAt | long | Unix timestamp of last activity (milliseconds) |
hasBlockedMe | boolean | Whether this user has blocked the logged-in user |
blockedByMe | boolean | Whether the logged-in user has blocked this user |
tags | Array<String> | List of tags for user identification and filtering |
deactivatedAt | long | Unix timestamp when user was deactivated (0 if active) |
Next Steps
User Presence
Track and subscribe to user online/offline status updates
Block Users
Block and unblock users to control interactions
User Management
Create, update, and manage user accounts
Send Messages
Start sending messages to retrieved users