Get the blacklist
Use getBlacklist() to retrieve the current user blacklist.
The blacklist records users blocked by the current account. Use it for a blacklist settings screen, relationship state on a profile card, or to limit a chat entry point. Blacklist management and group member management are separate capabilities; use Group APIs to mute, remove, or change the role of a group member.
Get the blacklist
After SDK initialization and login, call getBlacklist() to retrieve the full blacklist for the signed-in account. An empty list means no users are blocked.
OpenIMClient.getInstance().friendshipManager.getBlacklist(
new OnBase<List<UserInfo>>() {
@Override
public void onSuccess(List<UserInfo> users) {
blacklistStore.replace(users);
}
@Override
public void onError(int code, String error) {
recordBlacklistFailure(code, error);
}
}
);The callback returns List<UserInfo>; call UserInfo.getBlackInfo() to retrieve the blacklist relationship object.
Blacklist record fields
Common BlacklistInfo fields are:
| Field | Description |
|---|---|
userID | Target user ID blocked by the current user and the stable list key. |
nickname | Target user nickname snapshot. |
faceURL | Target user avatar URL. |
gender | Target user gender value. |
operatorUserID | User ID that performed the block operation. |
createTime | Blacklist relationship creation time. |
addSource | Source that added the blacklist relationship. |
ex | Blacklist relationship extension string. |
When the screen also needs friend remarks or the latest public profile, separately merge FriendInfo or PublicUserInfo by userID. Do not treat blacklist fields as friend profile data.
Merge blacklist state by userID. This query does not trigger blacklist added or deleted callbacks. Replace the local snapshot on initial load, after reconnecting, or after an explicit refresh; incremental changes are owned by the Block a user and Unblock a user listener pages.
Was this page helpful?