Browse SDKs · Android
SDKsAndroid

Delete a friend

Use deleteFriend() to remove one friendship from the current user.

Copy
OpenIMClient.getInstance().friendshipManager.deleteFriend(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Friend deletion succeeded.
        }

        @Override
        public void onError(int code, String error) {
            // Handle the error.
        }
    },
    friendUserID
);

A successful callback means the delete request completed; it does not mean that the friendship event has already arrived. onFriendDeleted(FriendInfo info) provides the removed friendship. Remove that user from the friend list by info.getUserID(). See Get the friend list by page for the complete listener, and query the list again when a complete refresh is required.