Skip to main content

Retrieve Logged In User Details

Use getLoggedInUser() to get the details of the logged-in user. Returns null if no user is logged in.
This method will return a User object containing all the information related to the logged-in user.

Retrieve List of Users

Use UsersRequestBuilder to configure filters, then call fetchNext() to retrieve users.

Set Limit

Set the number of users to fetch per request.

Set Search Keyword

Filter users by a search string.

Search In

Define which user property the searchKeyword should be searched in. Works only with setSearchKeyword(). By default, searches both UID and Name.

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.
If this parameter is not set, all available users will be returned.
If this parameter is not set, all users will be returned.

Hide Blocked Users

Exclude users blocked by the logged-in user from the results. Default is false.

Set Roles

Filter users by one or more roles.

Friends Only

Return only friends of the logged-in user when set to true.

Set Tags

Filter users by tags. Only users tagged with the specified tags are returned.

With Tags

Include tag data in the response when set to true.

Set UIDs

Fetch specific users by their UIDs. Maximum 25 UIDs per request.

Sort By

Sort the user list by a specific property. Default sort order is status => name => UID.

Sort By Order

Sort the user list in ascending or descending order. Default is ascending.

Fetch Users

After configuring the builder, call build() then fetchNext() to retrieve users. Call fetchNext() repeatedly on the same object to paginate.

Retrieve Particular User Details

Use getUser() to fetch details for a specific user by UID.
The getUser() method takes the following parameters: On success, the User object containing the details of the user is returned.

Get Online User Count

Use getOnlineUserCount() to get the total count of online users for your app.

User Payload Structure

The User object returned by SDK methods contains the following fields:Sample User Object:

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