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 another user to your blocklist is a one-way operation. For example: If you block User A by calling the corresponding RC SDK method, User A will be unable to 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.
-
There is an upper limit to the total number of users each person can block. For Chat Starter Plan and Chat Pro Plan, the limit is 3,000 blocked users.
-
When using server APIs to send one-to-one 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.
[[RCCoreClient sharedCoreClient] addToBlacklist:@"userId" success:^{
} error:^(RCErrorCode status) {
}];
| Parameter | Type | Description |
| :----------- | :------------------- | :------------------------------------------------------ |
| userId | NSString | The userId of the user to be added to the blocklist |
| successBlock | Block | Callback for successful blocklist addition |
| errorBlock | Block | Callback for failed blocklist addition. The `status` parameter returns the error code [RCErrorCode]. |
## Remove from Blocklist \{#remove}
You can remove a specified user (`userId`) from your blocklist by calling the `removeFromBlacklist:` method.
#### Method Signature
```objectivec
- (void)removeFromBlacklist:(NSString *)userId
success:(nullable void (^)(void))successBlock
error:(nullable void (^)(RCErrorCode status))errorBlock NS_SWIFT_NAME(removeFromBlacklist(_:success:error:));
#### Parameter Description
| Parameter | Type | Description |
| :----------- | :------------------- | :------------------------------------------------------ |
| userId | NSString | The userId of the user to be removed from the blocklist |
| successBlock | Block | Callback for successful blocklist removal |
| errorBlock | Block | Callback for failed blocklist removal. The `status` parameter returns the error code [RCErrorCode]. |
#### Example Code
```objectivec
[[RCCoreClient sharedCoreClient] removeFromBlacklist:@"userId" success:^{
} error:^(RCErrorCode status) {
}];
## Check Blocklist Status
You can check whether a specified user ID (`userId`) is in your blocklist by calling the `getBlacklistStatus:` method.
#### Method Signature
```objectivec
- (void)getBlacklistStatus:(NSString *)userId
success:(nullable void (^)(int bizStatus))successBlock
error:(nullable void (^)(RCErrorCode status))errorBlock;
#### Parameter Description
| Parameter | Type | Description |
| :----------- | :------------------- | :------------------------------------------------------ |
| userId | NSString | The userId of the user to check for blocklist status |
| successBlock | Block | Callback for successful query. `bizStatus` indicates whether the queried user is in the blocklist: 0 means the user is in the blocklist, 101 means not. |
| errorBlock | Block | Callback for failed query. The `status` parameter returns the error code [RCErrorCode]. |
#### Example Code
```objectivec
[[RCCoreClient sharedCoreClient] getBlacklistStatus:@"userId" success:^(int bizStatus) {
} error:^(RCErrorCode status) {
}];
## Get Blocklist
You can retrieve your blocklist by calling the `getBlacklist:` method.
#### Example Code
```objectivec
[[RCCoreClient sharedCoreClient] getBlacklist:^(NSArray *blockUserIds) {
} error:^(RCErrorCode status) {
}];
| Parameter | Type | Description |
| :----------- | :------------------- | :------------------------------------------------------ |
| successBlock | Block | Callback for successful query. `blockUserIds` returns an `NSArray` containing the user IDs in your blocklist |
| errorBlock | Block | Callback for failed query. The `status` parameter returns the error code [RCErrorCode]. |
<!-- links -->
[RCErrorCode]: https://doc.rongcloud.cn/apidoc/imlibcore-ios/latest/zh_CN/documentation/rongimlibcore/rcerrorcode?language=objc