Retrieve the blocklist
Retrieve the current user’s blocklist.
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:
| Property | Type | Description |
|---|---|---|
userID | NSString * _Nullable | The blocked user's ID, serving as the list entity key. |
nickname | NSString * _Nullable | Blocked user's display nickname. |
faceURL | NSString * _Nullable | Blocked user's avatar image URL. |
createTime | NSInteger | Timestamp when the user was added to the blacklist. |
addSource | NSInteger | Origin source identifier indicating how the block was initiated. |
operatorUserID | NSString * _Nullable | User ID of the account that executed the block action. |
attachedInfo | NSString * _Nullable | Reserved internal metadata string. |
ex | NSString * _Nullable | Custom 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
userIDas 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.
Was this page helpful?