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 Integration Guide.

Components


Implementation 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 react to the change.

2. Unblock User

Call CometChat.unblockUsers() with the target UID. On success, update the local user object and emit ccUserUnblocked to restore the composer.

3. Confirmation Dialog

Show a confirmation dialog before blocking. This prevents accidental blocks.

4. Composer Blocked State

When a user is blocked, the composer is replaced with an unblock prompt.

5. Event Listeners

Subscribe to block/unblock events to update the UI in real time. Clean up subscriptions in ngOnDestroy.

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.