Skip to main content
The CometChat SDK provides methods to retrieve the logged-in user, fetch filtered user lists, and look up individual users by UID. All user methods return User objects.

Get the Logged-In User

Use getLoggedInUser() to get the current user’s details. Returns nil if no user is logged in.
This method returns a User object containing all the information related to the logged-in user.

Retrieve List of Users

Use UsersRequestBuilder to fetch users with filtering, searching, and pagination.

Set Limit

Sets the number of users to fetch per request.

Set Search Keyword

Filters users by a search string.

Search In

Specifies which user properties to search. Works with set(searchKeyword:). By default, searches both UID and name.

Set Status

Filters users by online status:
  • CometChat.UserStatus.online — Only online users
  • CometChat.UserStatus.offline — Only offline users
If not set, returns all users.

Hide Blocked Users

When true, excludes users blocked by the logged-in user from the results.

Set Roles

Filters users by specified roles.

Friends Only

When true, returns only friends of the logged-in user.

Set Tags

Filters users by specified tags.

With Tags

When true, includes tag data in the returned user objects.

Set UIDs

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

Sort By

Sorts the user list by a specific property. Default sort order: status → name → UID. Pass "name" to sort by name → UID.

Sort By Order

Sets the sort order. Default is ascending. Use .desc for descending.
After configuring the builder, call build() to get the UsersRequest object, then call fetchNext() to retrieve users.

Retrieve Particular User Details

Use getUser() to fetch a specific user’s details by UID.
It returns a User object containing the details of the user.

Next Steps

User Presence

Track and subscribe to user online/offline status

Block Users

Block and unblock users from your application

User Management

Create, update, and delete users programmatically

Retrieve Conversations

Fetch conversation lists for your chat UI