Skip to main content
Friends lists are a great feature for improving your players’ ability to socialize. They’re easy to work with, and can make leaderboards more engaging for your users.

Prerequisites

SDK: Unity

  • The title ID is set in the PlayFabSharedSettings object.
  • The project can successfully log in a user.
  • The title has at least two registered users.

About friends

Any player in your title may be friends with any other player in your title. Notably, friendship on PlayFab is a one-way street. If Albert adds Bob as a friend, there is no approval process for Bob. In fact, Bob may be unaware. Bob must separately add Albert for the friendship to be mutual. If you wish to have reciprocity rules, it is your title’s responsibility to enforce these conditions with a custom game server or CloudScript logic, if necessary. In the event that a player has linked their Steam, Facebook, or XBOX Live account, their platform-specific friends can also be displayed, if those friends also play your title.

Making friends

The example code uses the functions DisplayFriends(), and DisplayError(string error) as a proxy of your app’s UI. You paste these into your editor to get it to work without any extra effort - or replace the calls with your own code.
  1. Once a player logs in, they can access the UI for friends. The functionality usually includes adding, removing, and displaying friends, at a minimum.
  2. To get the player’s current friends list, use the GetFriendsList API call.
The GetFriendsList result contains a parameter friends which is a list of FriendInfo objects.
  1. To add a friend to the player’s friend list, use the AddFriend API call.
  1. To remove a player from a player’s friends list, use the RemoveFriend API call.

Going further

There are other things you can do with friends besides adding, removing, and displaying.

Tagging friends

The FriendInfo object, retrieved from GetFriendsList, includes a list of tags for the friend. When updating the list, you would want to add and remove from this list, and include it in the API call (as shown below).
You can use tags to inform matchmaking (for example, the player doesn’t like playing with friends tagged 2tuff at hard difficulty), implement friend groups - or just use them to store any metadata associated with a relationship that you need. An important note is that PlayFab currently does not index these tags in any way. GetFriendsList can’t filter based on them, so that must be done locally. Keep this in mind when considering any performance implications resulting from this system.
Last modified on August 20, 2026