docs.unity3d.com
    Show / Hide Table of Contents

    Interface IFriendsService

    Definition of the friends service.

    IFriendsService is extending the IDisposable interface. Thus, the developer MUST call the .Dispose() method on the friends service singleton instance when they are done using the service implementing this interface.

    Namespace: Unity.Services.Friends
    Syntax
    public interface IFriendsService : IDisposable

    Methods

    AddFriendAsync(String, String)

    Async Operation. Creates a request to add a player to the current player friends list. This request will expire after 30 days.

    Declaration
    Task AddFriendAsync(string playerId, string eventSource = null)
    Parameters
    Type Name Description
    String playerId

    Identifier of the player

    String eventSource

    Source where the event occurred (e.g "chat"). Default is null.

    Returns
    Type Description
    Task

    Awaitable task

    Exceptions
    Type Condition
    ArgumentException

    Represents an error that occur when an argument is incorrectly setup.

    FriendsServiceException

    An exception containing the HttpClientResponse with headers, response code, and string of error.

    BlockAsync(String, String)

    Async Operation. Add a target player to current player block list.

    Declaration
    Task BlockAsync(string playerId, string eventSource = null)
    Parameters
    Type Name Description
    String playerId

    Identifier of the player

    String eventSource

    Source where the event occurred (e.g "chat"). Default is null.

    Returns
    Type Description
    Task

    Awaitable task

    Exceptions
    Type Condition
    ArgumentException

    Represents an error that occur when an argument is incorrectly setup.

    FriendsServiceException

    An exception containing the HttpClientResponse with headers, response code, and string of error.

    ConsentFriendRequestAsync(String)

    Async Operation. Consent the friend request from a player.

    Declaration
    Task ConsentFriendRequestAsync(string playerId)
    Parameters
    Type Name Description
    String playerId

    Identifier of the player

    Returns
    Type Description
    Task

    Awaitable task

    Exceptions
    Type Condition
    ArgumentException

    Represents an error that occur when an argument is incorrectly setup.

    FriendsServiceException

    An exception containing the HttpClientResponse with headers, response code, and string of error.

    GetBlocksAsync(PaginationOptions)

    Async Operation. Retrieve the current player block list.

    Declaration
    Task<List<Player>> GetBlocksAsync(PaginationOptions paginationOptions)
    Parameters
    Type Name Description
    PaginationOptions paginationOptions

    Pagination options

    Returns
    Type Description
    Task<List<Player>>

    List of players objects

    Exceptions
    Type Condition
    ArgumentException

    Represents an error that occur when an argument is incorrectly setup.

    FriendsServiceException

    An exception containing the HttpClientResponse with headers, response code, and string of error.

    GetFriendsAsync(PaginationOptions)

    Async Operation. Retrieve the current player friends list.

    Declaration
    Task<List<Player>> GetFriendsAsync(PaginationOptions paginationOptions)
    Parameters
    Type Name Description
    PaginationOptions paginationOptions

    Pagination options

    Returns
    Type Description
    Task<List<Player>>

    List of Player objects containing the player information.

    Exceptions
    Type Condition
    ArgumentException

    Represents an error that occur when an argument is incorrectly setup.

    FriendsServiceException

    An exception containing the HttpClientResponse with headers, response code, and string of error.

    GetFriendsAsync<T>(PaginationOptions)

    Declaration
    Task<List<PlayerPresence<T>>> GetFriendsAsync<T>(PaginationOptions paginationOptions)
        where T : new()
    Parameters
    Type Name Description
    PaginationOptions paginationOptions
    Returns
    Type Description
    Task<List<PlayerPresence<T>>>
    Type Parameters
    Name Description
    T

    GetInboxAsync(PaginationOptions)

    Async Operation. Retrieve the current player friend requests.

    Declaration
    Task<List<Player>> GetInboxAsync(PaginationOptions paginationOptions)
    Parameters
    Type Name Description
    PaginationOptions paginationOptions

    Pagination options

    Returns
    Type Description
    Task<List<Player>>

    List of players objects

    Exceptions
    Type Condition
    ArgumentException

    Represents an error that occur when an argument is incorrectly setup.

    FriendsServiceException

    An exception containing the HttpClientResponse with headers, response code, and string of error.

    IgnoreFriendRequestAsync(String)

    Async Operation. Ignore a friend request from another player.

    Declaration
    Task IgnoreFriendRequestAsync(string playerId)
    Parameters
    Type Name Description
    String playerId

    Identifier of the player

    Returns
    Type Description
    Task

    Awaitable task

    Exceptions
    Type Condition
    ArgumentException

    Represents an error that occur when an argument is incorrectly setup.

    FriendsServiceException

    An exception containing the HttpClientResponse with headers, response code, and string of error.

    RemoveFriendAsync(String)

    Async Operation. Remove a target player from the current player friend list.

    Declaration
    Task RemoveFriendAsync(string playerId)
    Parameters
    Type Name Description
    String playerId

    Identifier of the player

    Returns
    Type Description
    Task

    Awaitable task

    Exceptions
    Type Condition
    ArgumentException

    Represents an error that occur when an argument is incorrectly setup.

    FriendsServiceException

    An exception containing the HttpClientResponse with headers, response code, and string of error.

    SetPresenceAsync<T>(Presence<T>)

    Async Operation. Setter for the presence of the current player.

    Declaration
    Task SetPresenceAsync<T>(Presence<T> presence)
        where T : new()
    Parameters
    Type Name Description
    Presence<T> presence

    Presence of the player where T represents the Availability structure to save.

    Returns
    Type Description
    Task

    Awaitable task

    Type Parameters
    Name Description
    T

    The target type.

    Exceptions
    Type Condition
    ArgumentException

    Represents an error that occur when an argument is incorrectly setup.

    FriendsServiceException

    An exception containing the HttpClientResponse with headers, response code, and string of error.

    UnblockAsync(String)

    Async Operation. Remove a target player from the current player block list.

    Declaration
    Task UnblockAsync(string playerId)
    Parameters
    Type Name Description
    String playerId

    Identifier of the player

    Returns
    Type Description
    Task

    Awaitable task

    Exceptions
    Type Condition
    ArgumentException

    Represents an error that occur when an argument is incorrectly setup.

    FriendsServiceException

    An exception containing the HttpClientResponse with headers, response code, and string of error.

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023