SDKsiOS
Unblock a user
Remove a user from the current account’s blocklist with OpenIM iOS SDK.
Remove a user from the current account's blacklist using removeFromBlackList:onSuccess:onFailure:, restoring standard interaction and message delivery.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userID | NSString * | Yes | Target user ID to unblock. |
Code example
[[OIMManager manager] removeFromBlackList:targetUserID
onSuccess:^(NSString *data) {
[blacklistStore removeUserID:targetUserID];
}
onFailure:^(NSInteger code, NSString *message) {
NSLog(@"removeFromBlackList failed: %ld %@", (long)code, message);
}];Return value
The onSuccess callback signifies that OpenIMServer processed the unblock request and removed the user from the blacklist.
State changes after the call
- Local state merge: Remove the unblocked user from blacklist caches using
userIDas the unique entity key. - Asynchronous event listening: Multi-device sessions synchronize the removal via
onBlackDeleted:inOIMFriendshipListener. - Re-query calibration: To restore a complete snapshot of remaining blocked users, invoke Retrieve the blocklist.
@interface BlacklistStore () <OIMFriendshipListener>
@end
@implementation BlacklistStore
- (void)startListening {
[[OIMManager callbacker] addFriendListener:self];
}
- (void)stopListening {
[[OIMManager callbacker] removeFriendListener:self];
}
- (void)onBlackDeleted:(OIMBlackInfo *)info {
[self removeBlackInfoForUserID:info.userID];
}
@endRetain this listener instance strongly, and invoke removeFriendListener: when signing out or releasing the contacts model.
Was this page helpful?