Browse SDKs · iOS
SDKsiOS

Retrieve the blocklist

Retrieve the current user’s blocklist.

Copy

The OpenIMSDK blocklist records users whom the current user has blocked. Call getBlackListWithOnSuccess:onFailure: to retrieve the complete list as OIMBlackInfo records. Use this data to build a blocklist settings page, display relationship status on profile cards, or restrict access to chat actions.

Blocklists and group administration are separate capabilities. Use group-member APIs to mute or remove a member or change a group role. This query also does not indicate whether an account has been suspended at the platform level by the server.

Retrieve the blocklist

Call this selector after initializing the SDK and signing in. An empty array in the success callback means that the current user's blocklist is empty.

[[OIMManager manager] getBlackListWithOnSuccess:^(NSArray<OIMBlackInfo *> *items) {
    [blacklistStore replaceItems:items];
} onFailure:^(NSInteger code, NSString *message) {
    NSLog(@"getBlackList failed: %ld %@", (long)code, message);
}];

Profile cards, conversation action menus, and contact lists normally need only determine whether a particular userID is in the blocklist. Build a set keyed by userID; use fields such as nickname and avatar only for display.

Blocklist record properties

In the pinned SDK, OIMBlackInfo inherits from OIMPublicUserInfo. Use userID as the stable key when rendering the list. All string properties are declared nullable, so the UI should provide fallback values.

PropertyTypeDescription
userIDNSString * _NullableThe ID of the user blocked by the current user and the key used to merge list items.
nicknameNSString * _NullableThe target user's nickname, for display only.
faceURLNSString * _NullableThe target user's avatar URL.
createTimeNSIntegerThe time when the blocklist relationship was created.
addSourceNSIntegerThe source through which the blocklist relationship was added.
operatorUserIDNSString * _NullableThe ID of the user who performed the block operation.
attachedInfoNSString * _NullableAdditional information reserved by the SDK; parse it only when your application has an established format.
exNSString * _NullableAn extension field; parse only content whose format your application has defined.

If the blocklist page also displays friend remarks or other public profile details, merge those data sources by userID and keep the origins of OIMBlackInfo, OIMFriendInfo, and OIMPublicUserInfo distinct.

Results and incremental changes

The success callback returns the complete NSArray<OIMBlackInfo *> *; replace the current blocklist snapshot with it. This query only reads data and does not trigger a blocklist-added or blocklist-deleted delegate. Call the selector again to establish the complete list when first opening the page or when the user refreshes it. For write operations, see Block a user and Unblock a user.