SDKsAndroid
Delete a friend
Terminate friendship with a specified user using deleteFriend().
Terminate the bilateral friendship between the authenticated user and a target user.
Code example
OpenIMClient.getInstance().friendshipManager.deleteFriend(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Friend deleted successfully
}
@Override
public void onError(int code, String error) {
// Handle error
}
},
friendUserID
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback delivering the asynchronous operation result. |
friendUserID | String | Yes | Target user ID to unfriend. |
Return value
The successful callback indicates that the server terminated the friendship.
State changes after the call
Once the friendship is dissolved, the SDK triggers the onFriendDeleted(FriendInfo friend) event via OnFriendshipListener. Locate and remove the friend record matching friend.getUserID() from your local cache and update the UI.
For complete listener registration details, see Get the friend list. Deleting a friend does not purge conversation entries or chat history; to delete conversation history as well, see Delete a conversation and its messages.
Was this page helpful?