Welcome to Friends

Attention: The Digital Services Act (DSA) requires Unity to notify our customers’ end users if Unity takes an action which impacts those end users under the DSA. To comply with this requirement, if you use Unity Gaming Services (UGS) products that rely on the Unity Authentication Service, you must integrate the notification API by the effective date of the DSA: February 17, 2024. The notification API is ready for adoption in late January 2024.

For more information on DSA, refer to the Digital Services Act - compliance update.

To make your game compliant, refer to DSA notifications.

The Friends service allows you to boost player engagement by providing players with a social system that works well with other Unity services. With Friends, your players can:

Environments are logical partitions of Unity Game Services that contain data associated with your project. You can set the target environment in the Unity Cloud Dashboard and your initialization scripts.

The Friends API uses JSON Web Token (JWT) authentication. The Authentication SDK supports Anonymous authentication and Platform-specific authentication.

Understanding Friends

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 a user’s relationships one time at startup, then keeps the list up-to-date using push notifications.

The SDK sends change notifications as soon as the changes occur. User relationship changes that trigger a push notification include:

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 member's 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.