Blocklist Management
RC's blocklist feature means that after you add another user's userId to your blocklist, you will no longer receive any one-to-one chat messages sent by that user. Please note:
- Adding other users to your blocklist is a one-way operation. For example: If you block User A by calling the corresponding RC SDK method, User A cannot send you one-to-one chat messages and will receive a 405 error code. However, you can still send messages to User A, who can receive them normally.
- Each user has a maximum blocklist capacity. For Chat Starter Plan and Chat Pro Plan, the limit is 3,000 blocked users.
- When using the server API to send one-to-one chat messages, delivery is not restricted by blocklists by default. To enforce blocklist restrictions for server API messages, set the
verifyBlacklistparameter to1when calling the API.
Add to Blocklist
You can add a specified user (userId) to your blocklist by calling the addToBlacklist method. After successful addition, you can still send messages to the blocked user, but the blocked user cannot send you one-to-one chat messages.
Interface
RongIMClient.getInstance().addToBlacklist(userId, callback);
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| userId | String | User ID |
| callback | OperationCallback | Callback interface |
Remove from Blocklist
You can remove a specified user (userId) from your blocklist by calling the removeFromBlacklist method.
Interface
RongIMClient.getInstance().removeFromBlacklist(userId, callback);
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| userId | String | User ID |
| callback | OperationCallback | Callback interface |
Check Blocklist Status
You can check whether a specified user ID (userId) is in your blocklist by calling the getBlacklistStatus method.
Sample Code
RongIMClient.getInstance().getBlacklistStatus(userId,
new ResultCallback<BlacklistStatus>() {
@Override
public void onSuccess(BlacklistStatus blacklistStatus) {
}
@Override
public void onError(ErrorCode e) {
}
});
BlacklistStatus enum values:
- In blocklist:
IN_BLACK_LIST(0) - Not in blocklist:
NOT_IN_BLACK_LIST(1)
Get Blocklist
You can retrieve your blocklist by calling the getBlacklist method.
Sample Code
RongIMClient.getInstance()
.getBlacklist(
new GetBlacklistCallback() {
@Override
public void onSuccess(String[] strings) {
}
@Override
public void onError(ErrorCode e) {
}
});