Skip to main content

Facebook Friends

This feature allows retrieving the player's Facebook friends who also play the game.

To use this feature, Facebook Authorization must be enabled.


1. Configureโ€‹

Configuration is done in the
Settings Inspector โ†’ Facebook section
under the Base, iOS and Android tabs.


2. iOS Configurationโ€‹

Fill in the following fields
(ask your release manager for correct values):

  • Facebook Enabled โ€” enable/disable Facebook integration on iOS
  • Facebook Auth Enabled โ€” enable/disable Facebook Authorization on iOS
  • Facebook App Id โ€” your Facebook project ID
  • Facebook ClientToken โ€” Facebook Client Token

Note: Facebook friends retrieval requires Facebook Enabled, Facebook Auth Enabled and valid App Id / ClientToken.


3. Android Configurationโ€‹

Fill in the following fields in the Settings Inspector:

  • Facebook Enabled โ€” enable/disable Facebook integration
  • Facebook Auth Enabled โ€” enable/disable Facebook Authorization
  • Facebook App Id โ€” Facebook project ID
  • Facebook Game Link โ€” link to your game on Facebook (used for invites / sharing)
  • Facebook Game Preview โ€” preview image URL for game sharing

4. Usageโ€‹

Get Social Friendsโ€‹

To request the user's friend list:

P101XP.GetInstance().GetSocialFriends();

The result is delivered through SocialFriendsEvent.


5. Event Subscriptionโ€‹

Always subscribe before making the request:

private void SocialFriendsHandler(FriendsContainer friendsContainer)
{
}

P101XP.GetInstance().SocialFriendsEvent += SocialFriendsHandler;

Unsubscribe in OnDestroy to avoid duplicate callbacks:

P101XP.GetInstance().SocialFriendsEvent -= SocialFriendsHandler;

6. FriendsContainerโ€‹

public class FriendsContainer
{
public List<SocialFriend> friends;
public string error;
}

Fieldsโ€‹

FieldTypeDescription
friendsList<SocialFriend>List of friends playing this game
errorstringError message or null if request succeeded

7. SocialFriendโ€‹

public class SocialFriend
{
public int level;
public long mobileId;
public string name;
public string pictureUrl;
public string socialNetId;
}

Fieldsโ€‹

FieldTypeDescription
levelintPlayer's in-game level
mobileIdlong101XP mobile ID
namestringFriend's display name
pictureUrlstringURL to the friendโ€™s social avatar
socialNetIdstringSocial network user ID