Overview
When a user is blocked, they are prevented from sending messages to the person who blocked them. CometChat UIKit manages most of the related functionality automatically:- Composer Disabled: The message input area is not shown during conversations with blocked users.
- Unblock Option: A visible “Unblock” button allows users to lift the block.
- Messaging Limitations: Blocked users are restricted from initiating messages to the person who blocked them.
Prerequisites
- CometChat
SDK v4.xor later - CometChat App ID, Auth Key, and Region configured and initialized.
- React project setup with CometChat UI Kit
- Toast/confirmation UI components (e.g.,
CometChatConfirmDialog)
Components
Integration Steps
1. Detect Block Status
Update UI when block state changes.CometChatThreadedMessages.tsx
Ensures the composer and unblock UI reflect the current block state.
2. Hide Composer & Show Unblock UI
Define layout elements and their visibility toggles.CometChatHome.tsx
Prepares the UI containers for dynamic show/hide operations.
3. User Blocking Configuration
Call the unblock API and observe status updates.CometChatHome.tsx
Executes unblock logic and updates LiveData to refresh UI.
Error Handling & Blocked-User Handling
- Show toast feedback on success/failure
- Disable status and update UI for blocked users
- Properly catch and log deletion errors
Summary / Feature Matrix
Next Steps & Further Reading
React Sample App
Explore this feature in the CometChat Sample App.
UI Kit Source Code
Access the complete UI Kit source code on GitHub.