Browse SDKs · React Native
Platform
SDKsReact Native

Get blacklist

Retrieve the list of blocked users for the current account using the OpenIM React Native SDK.

Copy

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:

FieldTypeDescription
userIDstringBlacklisted user ID and primary reconciliation key.
nicknamestringNickname of the blacklisted user.
faceURLstringAvatar image URL of the blacklisted user.
ownerUserIDstringUser ID who owns this blacklist entry.
operatorUserIDstringUser ID of the operator who executed the blacklisting.
createTimenumberTimestamp when the entry was created in Unix milliseconds.
addSourcenumberSource channel for the blacklist entry.
exstringCustom 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.