Browse SDKs · iOS
Platform
SDKsiOS

Unblock a user

Remove a user from the current account’s blocklist with OpenIM iOS SDK.

Copy

Remove a user from the current account's blacklist using removeFromBlackList:onSuccess:onFailure:, restoring standard interaction and message delivery.

Parameters

ParameterTypeRequiredDescription
userIDNSString *YesTarget 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 userID as the unique entity key.
  • Asynchronous event listening: Multi-device sessions synchronize the removal via onBlackDeleted: in OIMFriendshipListener.
  • 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];
}

@end

Retain this listener instance strongly, and invoke removeFriendListener: when signing out or releasing the contacts model.