addBlack
Feature Introduction
Explanation
Add the other party to the blacklist.
Note
This means the other party cannot send you messages, but you can send messages to them. Relevant Callback: 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 | Mandatory | Description |
---|---|---|---|
userID | String | Yes | User ID |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
~ | ~ | If no exceptions are thrown, then added successfully |
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 | Mandatory | Description |
---|---|---|---|
userID | NSString | Yes | User ID |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
onSuccess | OIMSuccessCallback | Success Return |
onFailure | OIMFailureCallback | Failure Return |
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 | Mandatory | 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 | Mandatory | Description |
---|---|---|---|
userID | string | Yes | User ID |
ex | string | No | Extended field |
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 { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
IMSDK.addBlack({ toUserID: 'userID' })
.then(() => {
// Successful Call
})
.catch(({ errCode, errMsg }) => {
// Failed Call
});
Function Prototype
IMSDK.asyncApi('addBlack', operationID: string, {
toUserID: string;
ex?: string;
}): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for problem tracing, ensure uniqueness, recommended to use current time and random number |
userID | string | Yes | User ID |
ex | string | No | Extended field |
Return Result
Through the
openim-uniapp-polyfill
package, the function is Promise-based. When calling, usethen
andcatch
to 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(() => {
// Successful Call
})
.catch(({ errCode, errMsg }) => {
// Failed Call
});
Function Prototype
OpenIMSDKRN.addBlack({
toUserID: string;
ex?: string;
}, operationID: string): Promise<void>;
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
userID | string | Yes | User ID |
ex | string | No | Extended field |
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.addBlack({
toUserID: 'userID',
}, 'operationID')
.then(() => {
// Successful Call
})
.catch(({ errCode, errMsg }) => {
// Failed Call
});
### Function Prototype
public static void AddBlack(OnBase<bool> cb, string blackUserId, string ex)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | )nBase | Yes | Callback |
blackUserId | string | Yes | User ID |
ex | string | Yes | Extended field |
Return Result
Code Example
IMSDK.AddBlack((suc,errCode,errMsg)=>{
},"userId","");