Block a user
Use the AddBlockAsync
method to block another user. It returns an awaitable task or an error.
Parameter | Description |
---|---|
memberId | The unique identifier of the target user. |
The following code snippet shows the AddBlockAsync
definition.
/// <summary>
/// Creates a block towards the targeted user
/// </summary>
/// <param name="memberId">The Id of the target user.</param>
/// <returns>The relationship created</returns>
/// <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<Relationship> AddBlockAsync(string memberId);
The following code snippet shows how to block a target user for the current user.
// Initialize the Friends service
await FriendsService.Instance.InitializeAsync();
await FriendsService.Instance.AddBlockAsync(memberId);