question

HackerTester avatar image
HackerTester asked

How to Work With Tags In Playfab Friends?

Hey Me noob have no idea about Tags in playfab how to work i am not in game dev for long thats why my ques is silly

// Here's my code i don't know how to do it 

public void GetFriendsList(System.Action<GetFriendsListResult> result, System.Action<PlayFabError> error){
            GetFriendsListRequest request = new GetFriendsListRequest();
            request.IncludeSteamFriends = false;
            request.IncludeFacebookFriends = false;
            request.XboxToken = null;
            request.ProfileConstraints.ShowTags = true;

            PlayFabClientAPI.GetFriendsList(request, result=>{

	FriendList = result.Friends;

	foreach(friendinfo Friend in FriendList){

	Friend.Tags   // Don't Know What to do here plz help suppose i wanted to get tag for confirm now what to do ?
	
}


}, error);}
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Rick Chen avatar image
Rick Chen answered

Could you please tell us what you would like to do with the friend tag? Are you using the Unity?

Here is a example for checking the friend’s tags in Unity:

    public void GetFriendsList()
    {
        GetFriendsListRequest request = new GetFriendsListRequest();
        request.IncludeSteamFriends = false;
        request.IncludeFacebookFriends = false;
        request.XboxToken = null;
        request.ProfileConstraints.ShowTags = true;


        PlayFabClientAPI.GetFriendsList(request, result => {


            var FriendList = result.Friends;


            foreach (PlayFab.ClientModels.FriendInfo Friend in FriendList)
            {
                foreach(string tag in Friend.Tags)
                {
                    switch (tag)
                    {
                        case "your_defined_tag":
                            //do action
                            break;
                        default:
                            break;


                    }
                }
                
            }
        },
        OnFailure
        );
    
    }


    private void OnFailure(PlayFabError error)
    {
        Debug.Log(error.GenerateErrorReport());
    }
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

HackerTester avatar image HackerTester commented ·

@Rick Chen Getting null reference from setting GetfriendList request.profileconstraints.showtags = true; leading to null reference btw Tags in client options in game manager turned on and while login and register also show tags = true in request formation please tell what i am doing wrong...

2 Likes 2 ·
Rick Chen avatar image Rick Chen ♦ HackerTester commented ·

Assuming player A is trying to get the friend tag of player B. Please check if the following conditions are met.

  1. Has player A used AddFriend API to add player B as friend?
  2. Has player A used SetFriendTags API to add the friend tag on player B?
0 Likes 0 ·
UmarHyatt avatar image UmarHyatt HackerTester commented ·

same problem here. even i used add friend and set tag of player B

0 Likes 0 ·
HackerTester avatar image HackerTester commented ·

@Rick Chen Thanks Thats the Exact thing i wanted i just wanted to know the syntax

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.