tencent cloud

All product documents
Chat
Last updated: 2025-03-03 15:45:56
Unity
Last updated: 2025-03-03 15:45:56

Feature Description

To block a user's messages, add the user to the blocklist.

Blocklist

Blocking a user

Call the FriendshipAddToBlackList API (Details) to add a user to the blocklist, that is, block the user.
By default, a blocked user does not know that he/she is "blocked". After the user sends a message, the error code indicating that he/she has been blocked will not be returned. To have the "You have been blocked by the user" error message returned after a blocked user sends a message, you can log in to the Chat console, select Feature Configuration > Login and Message > Blocklist Check, and disable Show "Sent successfully" After Sending Messages. Then the SDK will report error code 20007 after a blocked user sends a message.
// Add a user to the blocklist
List<string> param = new List<string>
{
"user_id"
};
TIMResult res = TencentIMSDK.FriendshipAddToBlackList(param, (int code, string desc, List<FriendResult> result, string user_data)=>{
// Process the async logic
});

Unblocking a user

Call FriendshipDeleteFromBlackList (Details) to remove a user from the blocklist, after which messages from the user can be received.

// Remove a user from the blocklist
List<string> param = new List<string>
{
"user_id"
};
TIMResult res = TencentIMSDK.FriendshipDeleteFromBlackList(param, (int code, string desc, List<FriendResult> result, string user_data)=>{
// Process the async logic
});

Getting the blocklist

Call FriendshipGetBlackList (Details) to view how many users have been blocked and manage them.
// Get the blocklist
TIMResult res = TencentIMSDK.FriendshipGetBlackList((int code, string desc, List<FriendProfile> result, string user_data)=>{
// Process the async logic
});

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon