Directions:BLOCKED_BY_ME | HAS_BLOCKED_ME | BOTH (default)
Blocking a user prevents all communication between them and the logged-in user — messages, calls, and presence updates are all suppressed. You can block and unblock users by UID, and fetch the blocked users list with filtering and pagination.
BLOCKED_BY_ME — Users blocked by the logged-in user
HAS_BLOCKED_ME — Users who have blocked the logged-in user
BOTH — Both directions (default)
TypeScript
JavaScript
let limit: number = 30;let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() .setLimit(limit) .setDirection(CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME) .build();
let limit = 30;let blockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() .setLimit(limit) .setDirection(CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME) .build();
After configuring the builder, call build() to get the BlockedUsersRequest object, then call fetchNext() to retrieve blocked users.
TypeScript
JavaScript
let limit: number = 30;let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() .setLimit(limit) .build();blockedUsersRequest.fetchNext().then( (userList: CometChat.User[]) => { console.log("Blocked user list received:", userList); }, (error: CometChat.CometChatException) => { console.log("Blocked user list fetching failed with error:", error); });
const limit = 30;const blockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() .setLimit(limit) .build();blockedUsersRequest.fetchNext().then(userList => { console.log("Blocked user list received:", userList);}, error => { console.log("Blocked user list fetching failed with error:", error);});
The fetchNext() method returns an array of User objects representing blocked users.Relevant fields to access on returned users: