AI Integration Quick Reference
AI Integration Quick Reference
User objects.
Get the Logged-In User
UsegetLoggedInUser() to get the current user’s details. Returns nil if no user is logged in.
- Swift
- Objective C
User object containing all the information related to the logged-in user.
Retrieve List of Users
UseUsersRequestBuilder to fetch users with filtering, searching, and pagination.
Set Limit
Sets the number of users to fetch per request.- Swift
Set Search Keyword
Filters users by a search string.- Swift
Search In
Specifies which user properties to search. Works withset(searchKeyword:). By default, searches both UID and name.
- Swift
Set Status
Filters users by online status:CometChat.UserStatus.online— Only online usersCometChat.UserStatus.offline— Only offline users
- Swift
Hide Blocked Users
Whentrue, excludes users blocked by the logged-in user from the results.
- Swift
Set Roles
Filters users by specified roles.- Swift
Friends Only
Whentrue, returns only friends of the logged-in user.
- Swift
Set Tags
Filters users by specified tags.- Swift
With Tags
Whentrue, includes tag data in the returned user objects.
- Swift
Set UIDs
Fetches specific users by their UIDs. Maximum 25 users per request.- Swift
Sort By
Sorts the user list by a specific property. Default sort order:status → name → UID. Pass "name" to sort by name → UID.
- Swift
Sort By Order
Sets the sort order. Default is ascending. Use.desc for descending.
- Swift
build() to get the UsersRequest object, then call fetchNext() to retrieve users.
- Swift
- Objective C
Offline support
With offline support enabled (SDK 4.2.0 or later),fetchNext on a UsersRequest has an overload that first delivers onCachedUsers from the device, then onServerUsers with the live page to reconcile by uid. The cached page is the pages the server last returned for this exact request, replayed on the device. It is empty when nothing was recorded. Offline, the read ends with onError, code ERROR_INTERNET_UNAVAILABLE, after the cached page.
A request that uses a server-only filter records nothing, so its cached page is always empty.
See Show Cached Data.
Retrieve Particular User Details
UsegetUser() to fetch a specific user’s details by UID.
- Swift
- Objective C
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