Delete a friend

Use the DeleteFriendAsync method to remove a friend. It returns an awaitable task or an error.

ParameterDescription
memberIdThe unique identifier of the target user.

The following code snippet shows the DeleteFriendAsync definition.

/// <summary>
/// Deletes a friend.
/// </summary>
/// <param name="memberId">The Id of the friend to be deleted.</param>
/// <exception cref="System.ArgumentException">Represents an error that occur when an argument is incorrectly setup.</exception>
/// <exception cref="Unity.Services.Friends.Exceptions.RelationshipsServiceException">An exception containing the HttpClientResponse with headers, response code, and string of error.</exception>
Task DeleteFriendAsync(string memberId);

The following code snippet shows how to remove a friend from the current user's friend list.

// Initialize the Friends service
await FriendsService.Instance.InitializeAsync();
await FriendsService.Instance.DeleteFriendAsync(memberId);