Browse SDKs · iOS
Platform
SDKsiOS

Retrieve the blocklist

Retrieve the current user’s blocklist.

Copy

The OpenIM iOS SDK blacklist tracks accounts that the currently logged-in user has blocked. Invoke getBlackListWithOnSuccess:onFailure: to retrieve the complete collection of blocked users as OIMBlackInfo objects. Use this list to construct blacklist settings views, render block status indicators on user profiles, and restrict messaging actions.

Blacklists operate independently of group member mutes or room kicks. To restrict permissions within a group, invoke group member moderation APIs. This query also does not reflect server-side platform account suspensions.

Code example

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

Profile views and chat option sheets typically only require checking whether a given userID exists in the blacklist. Maintain a local lookup set keyed by userID.

Return value

The onSuccess callback delivers an NSArray<OIMBlackInfo *> * containing all blocked accounts:

PropertyTypeDescription
userIDNSString * _NullableThe blocked user's ID, serving as the list entity key.
nicknameNSString * _NullableBlocked user's display nickname.
faceURLNSString * _NullableBlocked user's avatar image URL.
createTimeNSIntegerTimestamp when the user was added to the blacklist.
addSourceNSIntegerOrigin source identifier indicating how the block was initiated.
operatorUserIDNSString * _NullableUser ID of the account that executed the block action.
attachedInfoNSString * _NullableReserved internal metadata string.
exNSString * _NullableCustom application extension string.

When combining blacklist views with friend remarks, merge records by userID while keeping OIMBlackInfo, OIMFriendInfo, and OIMPublicUserInfo models distinct.

State changes after the call

  • Local state merge: Replace or merge the blocklist snapshot using userID as the unique entity key.
  • Snapshot query: This query retrieves the current snapshot and does not emit delegate callbacks.
  • Modifications and events: To block or unblock users and monitor real-time blacklist events, refer to Block a user and Unblock a user.