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();
Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the BlockedUsersRequest class.Once you have the object of the BlockedUsersRequest class, you need to call the fetchNext() method. Calling this method will return a list of User objects containing n number of blocked users where N is the limit set in the builder class.
TypeScript
JavaScript
let limit = 30;let 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: