v1.0.0
Latest
2020.3+

Interface IFriendsService

FriendsService is the managed service that let's user's interact with the Friends package's features

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

Properties

Blocks

The list of the user's blocks.

Declaration
IReadOnlyList<Relationship> Blocks { get; }
Property Value
TypeDescription
IReadOnlyList<Relationship>
Exceptions
TypeCondition
InvalidOperationException

Represents an error that occurs when the service has not been initialized.

Friends

The list of the user's friends.

Declaration
IReadOnlyList<Relationship> Friends { get; }
Property Value
TypeDescription
IReadOnlyList<Relationship>
Exceptions
TypeCondition
InvalidOperationException

Represents an error that occurs when the service has not been initialized.

IncomingFriendRequests

The list of the user's incoming friend requests.

Declaration
IReadOnlyList<Relationship> IncomingFriendRequests { get; }
Property Value
TypeDescription
IReadOnlyList<Relationship>
Exceptions
TypeCondition
InvalidOperationException

Represents an error that occurs when the service has not been initialized.

OutgoingFriendRequests

The list of the user's outgoing friend requests.

Declaration
IReadOnlyList<Relationship> OutgoingFriendRequests { get; }
Property Value
TypeDescription
IReadOnlyList<Relationship>
Exceptions
TypeCondition
InvalidOperationException

Represents an error that occurs when the service has not been initialized.

Relationships

The full list of the user's relationships.

Declaration
IReadOnlyList<Relationship> Relationships { get; }
Property Value
TypeDescription
IReadOnlyList<Relationship>
Exceptions
TypeCondition
InvalidOperationException

Represents an error that occurs when the service has not been initialized.

Methods

AddBlockAsync(String)

Creates a block towards the targeted user.

Declaration
Task<Relationship> AddBlockAsync(string memberId)
Parameters
TypeNameDescription
StringmemberId

The ID of the target user.

Returns
TypeDescription
Task<Relationship>

The block created

Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

AddFriendAsync(String)

Creates a friend request, or automatically creates a friendship if the user already has an incoming friend request from the targeted user.

Declaration
Task<Relationship> AddFriendAsync(string memberId)
Parameters
TypeNameDescription
StringmemberId

The ID of the target user.

Returns
TypeDescription
Task<Relationship>

The friendship created

Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

AddFriendByNameAsync(String)

Creates a friend request, or automatically creates a friendship if the user already has an incoming friend request from the targeted user by their user name.

Declaration
Task<Relationship> AddFriendByNameAsync(string name)
Parameters
TypeNameDescription
Stringname

The name of the target user

Returns
TypeDescription
Task<Relationship>

The friendship created

Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

DeleteBlockAsync(String)

Deletes a block.

Declaration
Task DeleteBlockAsync(string memberId)
Parameters
TypeNameDescription
StringmemberId

The ID of the user that will be unblocked.

Returns
TypeDescription
Task
Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

RelationshipNotFoundException

Represents an error that occurs when a relationship is not found.

DeleteFriendAsync(String)

Deletes a friend.

Declaration
Task DeleteFriendAsync(string memberId)
Parameters
TypeNameDescription
StringmemberId

The ID of the friend to be deleted.

Returns
TypeDescription
Task
Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

RelationshipNotFoundException

Represents an error that occurs when a relationship is not found.

DeleteIncomingFriendRequestAsync(String)

Deletes an incoming friend request.

Declaration
Task DeleteIncomingFriendRequestAsync(string memberId)
Parameters
TypeNameDescription
StringmemberId

The ID of the user that sent the friend request.

Returns
TypeDescription
Task
Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

RelationshipNotFoundException

Represents an error that occurs when a relationship is not found.

DeleteOutgoingFriendRequestAsync(String)

Deletes an outgoing friend request.

Declaration
Task DeleteOutgoingFriendRequestAsync(string memberId)
Parameters
TypeNameDescription
StringmemberId

The ID of the user that a friend request was sent to.

Returns
TypeDescription
Task
Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

RelationshipNotFoundException

Represents an error that occurs when a relationship is not found.

DeleteRelationshipAsync(String)

Deletes a relationship.

Declaration
Task DeleteRelationshipAsync(string relationshipId)
Parameters
TypeNameDescription
StringrelationshipId

The ID of the relationship to be deleted.

Returns
TypeDescription
Task
Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

ForceRelationshipsRefreshAsync()

Forcefully refreshes the list of relationships in case they were not refreshed automatically by the service

Declaration
Task ForceRelationshipsRefreshAsync()
Returns
TypeDescription
Task
Exceptions
TypeCondition
FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

InitializeAsync(InitializeOptions)

Initialize the Friends service API. This must be called before using any other functionality of the Friends service. This can only be called when a user is signed in.

Declaration
Task InitializeAsync(InitializeOptions initializeOptions = null)
Parameters
TypeNameDescription
InitializeOptionsinitializeOptions

Options to initialize the Friends service

Returns
TypeDescription
Task
Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

SetPresenceActivityAsync<T>(T)

Sets the user's presence activity value.

Declaration
Task SetPresenceActivityAsync<T>(T activity)
    where T : new()
Parameters
TypeNameDescription
Tactivity

The activity value to be set for the user's presence.

Returns
TypeDescription
Task
Type Parameters
NameDescription
T
Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

SetPresenceAsync<T>(Availability, T)

Sets the presence for the user.

Declaration
Task SetPresenceAsync<T>(Availability availabilityOption, T activity)
    where T : new()
Parameters
TypeNameDescription
AvailabilityavailabilityOption

The type of availability to be set for the user's presence.

Tactivity

The activity value to be set for the user's presence.

Returns
TypeDescription
Task
Type Parameters
NameDescription
T
Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

SetPresenceAvailabilityAsync(Availability)

Sets the user's presence availability.

Declaration
Task SetPresenceAvailabilityAsync(Availability availabilityOption)
Parameters
TypeNameDescription
AvailabilityavailabilityOption

The type of availability to be set for the user's presence.

Returns
TypeDescription
Task
Exceptions
TypeCondition
ArgumentException

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

FriendsServiceException

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

InvalidOperationException

Represents an error that occurs when the service has not been initialized.

Events

MessageReceived

Event called when a message is received.

Declaration
event Action<IMessageReceivedEvent> MessageReceived
Event Type
TypeDescription
Action<IMessageReceivedEvent>

PresenceUpdated

Event called when a friend's presence is updated.

Declaration
event Action<IPresenceUpdatedEvent> PresenceUpdated
Event Type
TypeDescription
Action<IPresenceUpdatedEvent>

RelationshipAdded

Event called when a relationship gets added.

Declaration
event Action<IRelationshipAddedEvent> RelationshipAdded
Event Type
TypeDescription
Action<IRelationshipAddedEvent>

RelationshipDeleted

Event called when a relationship gets deleted.

Declaration
event Action<IRelationshipDeletedEvent> RelationshipDeleted
Event Type
TypeDescription
Action<IRelationshipDeletedEvent>