Browse SDKs · Android
SDKsAndroid

Get the blacklist

Use getBlacklist() to retrieve the current user blacklist.

Copy

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.

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) {
            // Use users to update the blacklist.
        }

        @Override
        public void onError(int code, String error) {
            // Handle the error.
        }
    }
);

The callback returns List<UserInfo>; call UserInfo.getBlackInfo() to retrieve the blacklist relationship object.

Blacklist record fields

Common BlacklistInfo fields are:

FieldDescription
userIDTarget user ID blocked by the current user.
nicknameTarget user nickname.
faceURLTarget user avatar URL.
genderTarget user gender value.
operatorUserIDUser ID that performed the block operation.
createTimeBlacklist relationship creation time.
addSourceSource that added the blacklist relationship.
exBlacklist relationship extension string.

When the screen also needs friend remarks or the latest public profile, query the corresponding friend or public profile data.

Receive blacklist changes through the listeners described in Block a user and Unblock a user.