Relationships

The Friends service manages relationships of different types. In general, most user relationships don’t change often; however, there are updates users often want to know about as soon as possible. To increase efficiency, the Friends SDK fetches all of a user’s relationships one time at startup, then keeps the list up to date using push notifications.

A relationship is a status between two users. Some relationship statuses require consent from both users and others only require consent from one user. The Friends SDK automatically groups the different relationships and exposes a collection for each relationship type. The relationship types include friend requests, friends, and blocks.

  • The friend requests collection includes all incoming and outgoing friend requests. The role property of the relationship members identifies whether it’s incoming or outgoing. Refer to friend request. The maximum number of pending friend requests (both incoming AND outgoing) is 10.
  • The friends collection has all of a user’s active friendships. Refer to friends list. The maximum number of active friendships is 50.
  • The blocks collection has all the users a user has blocked. Refer to block list. The maximum number of active blocks is 10.

Note: The limits on the number of different relationships might change. If these limits are too low for your purposes, please contact Unity Support to discuss.

The Friends service treats all relationships the same. You can use the various properties of each relationship to decide how to treat that relationship. Each relationship has one or more members (players), each of which might have extra properties that identify that member’s role in the relationship. For example, a FRIEND_REQUEST relationship always has two members:

  1. A member with a SOURCE role (the sender).
  2. A member with a TARGET role (the receiver).

However, the members role changes to NONE when a FRIEND_REQUEST relationship changes to a FRIEND relationship.

The SDK provides some wrapper APIs for specific operations to increase the service’s usability.

For example, when you call the SendFriendRequestAsync method, it calls the CreateRelationship API and creates a new FRIEND_REQUEST relationship with the target user.

If there’s already a FRIEND_REQUEST relationship from the target user, it creates a new FRIEND relationship. Depending on the state, SendFriendRequestAsync can result in a FRIEND_REQUEST or a new FRIEND relationship.

Note: A relationship status is separate from a user's presence status.

When two users have a friend relationship, each user exists on the other user's friends list. This relationship type requires consent from both users, but only one user needs to start the creation of the relationship by sending a friend request.

Two users have a block relationship when one user blocks another user (by adding them to their block list). This relationship type only requires consent from the user performing the block.