question

Nathan Leadbitter avatar image
Nathan Leadbitter asked

Getting User Title Data with Login Request

Hi all,

I am using the latest Unity SDK, and when my player wants to log in, I'm calling this function:

public void Login(string Username, string Password) {

GetPlayerCombinedInfoRequestParams paramters = new GetPlayerCombinedInfoRequestParams(){
	GetPlayerProfile = true,
	GetTitleData = true,
        GetUserVirtualCurrency = true,
        GetUserInventory = true
};

PlayFabClientAPI.LoginWithPlayFab(new LoginWithPlayFabRequest {
            Username = Username,
            Password = Password,
            InfoRequestParameters = paramters
        }, LoginSuccess, GetPlayFabError);
    }

On success, this then runs a login success function which contains:

        if (Result.InfoResultPayload.TitleData.ContainsKey("XP")) {
            Data.Experience = Result.InfoResultPayload.TitleData["XP"];
        } else {
            Data.Experience = "0";
            CreateBasicUserData();
        }

This is a test account I've been using, and for that account, the "XP" key is set. However the InfoRequestPayload.TitleData is empty, so using something like

Result.InfoResultPayload.TitleData.ToList().ForEach(x => Debug.Log(x.Key));

Returns nothing at all, and thus the else part of the login success gets executed, everytime.

The documentation states that this login method can be sent with a

unity3d
10 |1200

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

Nathan Leadbitter avatar image
Nathan Leadbitter answered

Solved it, if anyone has a similar issue as me, Title Data in the getplayercombinedinforequestparams is not the USER title data, jokes on me for not reading the documentation properly. Use UserData instead and access the values like Result.InfoResultPayload.UserData["KEYNAME"].Value

10 |1200

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

Nathan Leadbitter avatar image
Nathan Leadbitter answered

Am I supposed to be using GetUserData = true instead of GetTitleData=true?

10 |1200

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

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.