SDKsHarmonyOSEnterprise
Add user to blocklist
Add a designated user to the current account’s blocklist.
Block a specific user ID to prevent unwanted contact:
Code example
import sdk, { AddBlackReq } from '@openimsdk/imsdk';
const request: AddBlackReq = {
userID: targetUserID,
ex: '',
};
await sdk.addBlack(request);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userID | string | Yes | Target user identifier to block. |
ex | string | No | Custom application metadata string. |
Return value
Returns a Promise that resolves to void upon saving the blocklist record on the server.
State changes after the call
Resolving the Promise initiates the blocklist update. Correlate local blocklist records using blockUserID (matching the target userID) when EventOnBlackAdded arrives; see Retrieve blocklist for listener patterns. Adding a user to the blocklist does not automatically purge chat history; manage conversation visibility separately in application code.
Was this page helpful?