SDKsReact Native
Get blacklist
Retrieve the list of blocked users for the current account using the OpenIM React Native SDK.
Retrieve the complete list of blacklisted users for the authenticated account:
const blockedUsers = await OpenIMSDK.getBlackList();Return value
Resolves to an array of BlackUserItem[] records:
| Field | Type | Description |
|---|---|---|
userID | string | Blacklisted user ID and primary reconciliation key. |
nickname | string | Nickname of the blacklisted user. |
faceURL | string | Avatar image URL of the blacklisted user. |
ownerUserID | string | User ID who owns this blacklist entry. |
operatorUserID | string | User ID of the operator who executed the blacklisting. |
createTime | number | Timestamp when the entry was created in Unix milliseconds. |
addSource | number | Source channel for the blacklist entry. |
ex | string | Custom extension string. |
When checking blacklist relations in profile cards or chat windows, match by userID. Blacklisting is independent of group permissions; use group APIs to mute or kick group members.
Listen for blacklist changes
Blacklist additions and removals trigger OnBlackAdded or OnBlackDeleted with the affected BlackUserItem:
const handleBlackAdded = (blackUser: BlackUserItem) => {
// Add or update blacklist cache matching blackUser.userID
};
const handleBlackDeleted = (blackUser: BlackUserItem) => {
// Remove entry matching blackUser.userID from blacklist cache
};
// Register listeners
OpenIMSDK.on(OpenIMEvent.OnBlackAdded, handleBlackAdded);
OpenIMSDK.on(OpenIMEvent.OnBlackDeleted, handleBlackDeleted);
// Remove listeners
OpenIMSDK.off(OpenIMEvent.OnBlackAdded, handleBlackAdded);
OpenIMSDK.off(OpenIMEvent.OnBlackDeleted, handleBlackDeleted);Unregister these listeners when the screen unmounts, the user signs out, or accounts switch.
Was this page helpful?