SDKsAndroid
Block a user
Use addBlacklist() to add a user to the current account blacklist.
OpenIMClient.getInstance().friendshipManager.addBlacklist(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// User blocked successfully.
}
@Override
public void onError(int code, String error) {
// Handle the error.
}
},
targetUserID,
"{\"source\":\"profile-menu\"}"
);The second argument is the target userID, and the third argument is optional extension data. Use the overload without ex when no extension data is needed. A successful callback means the block request completed, not that the event has arrived.
The blacklist is one-way: the blocked user cannot send messages to the current account. Whether the current account can continue to send messages is an application-level rule. ex stores blacklist extension data and can contain a JSON string.
Receive onBlacklistAdded through OnFriendshipListener:
@Override
public void onBlacklistAdded(BlacklistInfo user) {
// Handle the added blacklist record.
}Was this page helpful?