addBlack
Description
info
Add the other party to the blocklist.
Note
Means they cannot send messages to you, but you can send messages to them.
Related callbacks:
onBlackAdded
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<dynamic> addBlacklist({
required String userID,
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| userID | String | Yes | User ID |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| ~ | ~ | Added successfully if no exception is thrown |
Code Example
await OpenIM.iMManager.friendshipManager.addBlacklist(userID: 'userID');
// todo
Function Prototype
- (void)addToBlackList:(NSString *)userID
onSuccess:(OIMSuccessCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| userID | NSString | Yes | User ID |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| onSuccess | OIMSuccessCallback | Success |
| onFailure | OIMFailureCallback | Failure |
Code Example
[OIMManager.manager addToBlackList:@""
onSuccess:^(NSString * _Nullable data) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void addBlacklist(OnBase<String> callBack, String uid)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| callBack | OnBase | Yes | Callback interface |
| uid | String | Yes | User ID |
Return Result
Code Example
OpenIMClient.getInstance().friendshipManager.addBlacklist(new OnBase<String>(){...},uid)
Function Prototype
IMSDK.addBlack({
toUserID: string;
ex?: string;
}, operationID?: string): Promise<WsResponse>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| userID | string | Yes | User ID |
| ex | string | No | Extended field, carried to the user's blacklist information |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse> | Success callback |
| Promise.catch() | Promise<WsResponse> | Failure callback |
Code Example
import { getSDK } from '@openim/wasm-client-sdk';
const IMSDK = getSDK();
// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();
// use in mini program
// import { getSDK } from '@openim/client-sdk';
// const IMSDK = getSDK();
IMSDK.addBlack({ toUserID: 'userID' })
.then(() => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
IMSDK.asyncApi('addBlack', operationID: string, {
toUserID: string;
ex?: string;
}): Promise<void>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| userID | string | Yes | User ID |
| ex | string | No | Extended field |
Return Result
Use the
openim-uniapp-polyfillpackage to make the function Promise. When calling, you need to usethenandcatchto determine and handle success and failure callbacks.
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<void> | Success callback |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('addBlack', IMSDK.uuid(), { toUserID: 'userID' })
.then(() => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
OpenIMSDK.addBlack({
toUserID: string;
ex?: string;
}, operationID?: string): Promise<void>;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| userID | string | Yes | User ID |
| ex | string | No | Extended field |
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<void> | Success callback |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
OpenIMSDK.addBlack({
toUserID: 'userID',
})
.then(() => {
// Success
})
.catch((error) => {
// Failure
});
Function Prototype
public static void AddBlack(OnBase<bool> cb, string blackUserId, string ex)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| cb | OnBase | Yes | Callback |
| blackUserId | string | Yes | User ID |
| ex | string | Yes | Custom field |
Return Result
Code Example
IMSDK.AddBlack((suc,errCode,errMsg)=>{
},"userId","");