Delete a friend request

You can use the Friends SDK to delete incoming and outgoing friend requests.

Delete an incoming friend request

Use the DeleteIncomingFriendRequestAsync to delete an incoming friend request from another user. It returns an awaitable task or an error.

ParameterDescription
memberIdThe unique identifier of the target user.

The following code snippet shows the DeleteIncomingFriendRequestAsync definition.

/// <summary>
/// Deletes an incoming friend request.
/// </summary>
/// <param name="memberId">The Id of the user that sent the friend request.</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 DeleteIncomingFriendRequestAsync(string memberId);

The following code snippet shows how to delete an incoming friend request to the current user.

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

Delete an outgoing friend request

Use the DeleteOutgoingFriendRequestAsync to delete an outgoing friend request to another user. It returns an awaitable task or an error.

ParameterDescription
memberIdThe unique identifier of the target user.

The following code snippet shows the DeleteOutgoingFriendRequestAsync definition.

/// <summary>
/// Deletes an outgoing friend request.
/// </summary>
/// <param name="memberId">The Id of the user that a friend request was sent to.</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 DeleteOutgoingFriendRequestAsync(string memberId);

The following code snippet shows how to delete an outgoing friend request from the current user.

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