please select
  • UIKit
  • SDK
  • Server APIs
Chat/
SDK/
Flutter/
User/
SDK
  • Install Chat SDK
    • Install
  • Initialize Chat SDK
    • Initialize
  • Login And Logout
    • Login and Logout
  • Message
    • Message Overview
    • Sending Message
    • Receiving Message
    • Historical Message
    • Forwarding Message
    • Modifying Message
    • Message Inserting
    • Deleting Message
    • Clearing Messages
    • Recalling Message
    • Online Message
    • Read Receipt
    • Querying Message
    • Group @ Message
    • Targeted Group Message
    • Notification Muting
    • Message Extension
  • Conversation
    • Conversation Overview
    • Conversation List
    • Getting Conversation
    • Conversation Unread Count
    • Pinning Conversation to the Top
    • Deleting Conversation
    • Conversation Draft
    • Conversation Group
  • Group
    • Group Overview
    • Group Management
    • Group Profile
    • Group Member Management
    • Group Member Profile
    • Custom Group Attribute
  • User
    • User Profile
    • Friend Management
    • Friend List
    • Blocklist
  • Offline Push
    • Offline Push
  • Signaling
    • Signaling Management
  • Local Search
    • Searching for Message
    • Searching for Friend
    • Searching Group
    • Searching for Group Member
  • API Reference
    • Client APIs
  • Guideline for Beginners
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes

Blocklist

Feature Description

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

Blocklist

Blocking a user

Call the addToBlackList 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 IM 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
V2TimValueCallback<List<V2TimFriendOperationResult>> addBlackList = await friendshipManager.addToBlackList(userIDList: ['user1']);

Unblocking a user

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

// Remove a user from the blocklist
V2TimValueCallback<List<V2TimFriendOperationResult>> deleteBlackList = await friendshipManager.deleteFromBlackList(userIDList: ['user1']);

Getting the blocklist

Call getBlackList (Details) to view how many users have been blocked and manage them.
// Get the blocklist
V2TimValueCallback<List<V2TimFriendInfo>> blacklist = await friendshipManager.getBlackList();