tencent cloud

Chat

News and Announcements
Release Notes
Announcements
Product Introduction
Overview
Basic Concepts
Scenarios
Features
Account System
User Profile and Relationship Chain
Message Management
Group Related
Official Account
Audio/Video Call
Use Limits
Purchase Guide
Billing Overview
Pricing
Purchase Instructions
Renewal Guide
Service Suspension Explanation
Refund Policy
Development Guidelines
Demo Zone
Activate Service
Free Demos
Quick Run
Download
SDK and Demo Source Code
Update Log
Chat Interaction (UI Included)
TUIKit Introduction
Getting Started
Full-feature Integration
Single-function Integration
Build with AI
Build Basic Interfaces
More Features
Customizing Appearance
Internationalization
Push Service
Overview
Noun explanation
Activate the Service
Quick Start
Manufacturer Channel
Statistics
Troubleshooting Tool
Client APIs
REST API
Push Callback
Advanced Features
Release Notes
Error Codes
FAQS
Desk
Overview
Quick Start
Integration Guide
Admin Operation Manual
Agent Manual
More Practices
Live Streaming Setup Guide
AI Chatbot
Super Large Entertainment and Collaboration Community
Discord Implementation Guide
How to Integrate Chat into Games
WhatsApp Channel-style Official Account Integration Solution
Send Red Packet
Firewall Restrictions
No UI Integration
Quick Start
SDK Integration
Initialization
Login and Logout
Message
Conversation
Group
Community Topic
User Profile and Relationship Chain
Offline Push
Cloud Search
Local Search
Official Channel Management
Client APIs
JavaScript
Android
iOS & macOS
Swift
Flutter
Electron
Unity
React Native
C APIs
C++
Server APIs
Secure authentication with UserSig
RESTful APIs
Webhooks
Console Guide
New Console Introduction
Creating and Upgrading an Application
Basic Configuration
Feature Configuration
Account Management
Group Management
Official Channel Management
Webhook Configuration
Usage
Viewing Guide for Resource Packages
Real-Time Monitor
Auxiliary Development Tools
Access Management
Advanced Features
FAQs
uni-app FAQs
Purchase
SDK
Account Authentication
User Profile and Relationship Chain
Message
Group
Audio-Video Group
Nickname and Profile Photo
Security Compliance Certification
Service Level Agreement
Security Compliance Certification
Chat Policies
Privacy Policy
Data Privacy and Security Agreement
Migration
Migration Solutions
Migration Solutions Lite
Error Codes
Contact Us

React Native

PDF
Focus Mode
Font Size
Last updated: 2025-01-07 16:18:24

Feature Overview

To block a user's messages, add the user to the blocklist.
Note:
1. The maximum limit for the blocklist is 1000, and it cannot be adjusted.
2. If you need to add a friend to the blocklist while still maintaining the friendship, go to the Chat console, find the corresponding SDKAppID, navigate to Chat > Configuration > Friends and Relationship > Block configuration, and select Remain Friends.

Blocking a user

By adding a user to the blocklist, you can block all the messages sent by the user. Therefore, this API can be used to block the messages of a specified user.
If user A and user B are friends, the two-way friend relationship is terminated when either A or B is blocked by the other user.
If either user A or user B is blocked by the other user, neither user A nor user B can start a conversation with the other user.
If either user A or user B is blocked by the other user, neither user A nor user B can send a friend request to the other user.
API
chat.addToBlacklist(options);
Parameters
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Description
userIDList
Array
List of userID values of the users to be added to the blocklist. The number of userID values cannot exceed 1,000 per request.
Return value
Promise
Examples
let promise = chat.addToBlacklist({userIDList: ['user1', 'user2']});
promise.then(function(imResponse) {
console.log(imResponse.data);
console.warn('addToBlacklist error:', imError); // Failed to add the user to the blocklist
});

Unblocking a user

After a user is removed from the blocklist, messages from the user can be received.
API
chat.removeFromBlacklist(options);
Parameters
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Description
userIDList
Array
List of userID values of the users to be removed from the blocklist. The number of userID values cannot exceed 1,000 per request.
Return value
Promise
Examples
let promise = chat.removeFromBlacklist({userIDList: ['user1', 'user2']});
console.log(imResponse.data);
console.warn('removeFromBlacklist error:', imError); // Failed to remove the user from the blocklist
});

Getting the blocklist

The blocklist cached in the SDK can be obtained.
API
chat.getBlacklist();
Return value
Promise
Examples
let promise = chat.getBlacklist();
promise.then(function(imResponse) {
console.log(imResponse.data);
}).catch(function(imError) {
console.warn('getBlacklist error:', imError); // Failed to obtain the blocklist
});

Notification of a change in the blocklist

When a blocklist is updated, the SDK will deliver the TencentCloudChat.EVENT.BLACKLIST_UPDATED event.
Examples
let onBlacklistUpdated = function(event) {
console.log(event.data);
};
chat.on(TencentCloudChat.EVENT.BLACKLIST_UPDATED, onBlacklistUpdated);


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback