AI Integration Quick Reference
AI Integration Quick Reference
User objects.
User Object Fields
Retrieve Logged In User Details
UsegetLoggedInUser() to get the current user’s details. Returns null if no user is logged in.
- Dart
User object with the logged-in user’s information.
Retrieve List of Users
In order to fetch the list of users, you can use theUsersRequest class. To use this class i.e to create an object of the UsersRequest class, you need to use the UsersRequestBuilder class. The UsersRequestBuilder class allows you to set the parameters based on which the users are to be fetched.
Fetching using this builder will return User objects.
UsersRequestBuilder Parameters
The
UsersRequestBuilder class allows you to set the below parameters:
Set Limit
Sets the number of users to fetch per request.- Dart
Set Search Keyword
Filters users by a search string.- Dart
Search In
Specifies which user properties to search. Works withsearchKeyword. By default, searches both UID and name.
- Dart
Set Status
Filters users by online status:CometChatUserStatus.online— Only online usersCometChatUserStatus.offline— Only offline users
- Dart
Hide Blocked Users
Whentrue, excludes users blocked by the logged-in user from the results.
- Dart
Set Roles
Filters users by specified roles.- Dart
Friends Only
Whentrue, returns only friends of the logged-in user.
- Dart
Set Tags
Filters users by specified tags.- Dart
With Tags
Whentrue, includes tag data in the returned user objects.
- Dart
Set UIDs
Fetches specific users by their UIDs. Maximum 25 users per request.- Dart
Sort By
Sorts the user list by a specific property. Default sort order:status → name → UID. Pass "name" to sort by name → UID.
- Dart
Sort By Order
Sets the sort order. Default is ascending ("asc"). Use "desc" for descending.
- Dart
build() to get the UsersRequest object, then call fetchNext() to retrieve users.
- Dart
fetchNext() method returns a list of User objects.
Response
Response
On Success — A list of
User objects matching the request filters. Each item in the list contains:User Object:Error
Error
Retrieve Particular User Details
UsegetUser() to fetch a specific user’s details by UID.
- Dart
getUser() method takes the following parameters:
On success, the
User object containing the details of the user is returned.
Response
Response
On Success — A
User object containing the details of the requested user:User Object:Error
Error
Get Online User Count
UsegetOnlineUserCount() to get the total number of online users in your app.
- Dart
getOnlineUserCount() resolves with an int representing the total count of currently online users in your app.
Response
Response
On Success — An
int value representing the total count of online users:Error
Error
Next Steps
User Presence
Monitor and manage real-time user online/offline status
Block Users
Block and unblock users to control interactions
User Management
Create, update, and delete users programmatically
Users Overview
Explore all user-related features and capabilities