Skip to main content
Block/Unblock lets users prevent specific users from sending them messages. When blocked, the message composer is hidden and replaced with an unblock prompt. Before starting, complete the Getting Started guide for your framework.

Components


Integration Steps

1. Block User

Call CometChat.blockUsers() with the target UID. On success, update the local user object with setBlockedByMe(true) and emit ccUserBlocked so all subscribed components (like the composer) react to the change. File: CometChatHome.tsx

2. Unblock User

Call CometChat.unblockUsers() with the target UID. On success, reset the action items back to “Block” (instead of “Unblock”), update the local user object, and emit ccUserUnblocked to restore the composer. File: CometChatHome.tsx

3. Confirmation Dialog

Show a confirmation dialog before blocking. This prevents accidental blocks. The dialog uses CometChatConfirmDialog with localized title, message, and button text. File: CometChatHome.tsx

4. Composer Blocked State

File: CometChatMessages.tsx When a user is blocked, the composer is replaced with an unblock prompt:

5. Event Listeners

File: CometChatHome.tsx Subscribe to block/unblock events to update the UI in real time:

Feature Matrix


Next Steps

Users

Display and manage user lists.

Message Composer

Customize the message input component.

All Guides

Browse all feature and formatter guides.

Sample App

Full working sample application on GitHub.