question

spartan666nm avatar image
spartan666nm asked

GetPlayerProfile.Locations returns null

although i have set it to show location in the setting/Client profile options and I have created a

PlayerProfileViewConstraints and set locations true there as well and I Give that to my GetPlayerProfile Call it again returns null here's my code for it

var request = new GetPlayerProfileRequest
        {
            PlayFabId = result.PlayFabId
        };

        PlayerProfileViewConstraints playerProfileViewConstraints = new PlayerProfileViewConstraints
        {
            ShowLocations = true
        };

        PlayFabClientAPI.GetPlayerProfile(request, OnGetPlayerProfileSuccessCallback, OnGetPlayerProfileFailureCallback , playerProfileViewConstraints);

the above code is executed after the player has registered an account and is logged in

then in

OnGetPlayerProfileSuccessCallback

I will access the information and they are null:

    void OnGetPlayerProfileSuccessCallback(GetPlayerProfileResult result)
    {
        Debug.LogWarning("playerprofile.displayName  -  " + result.PlayerProfile.DisplayName);
        Debug.LogWarning("playerprofile.PlayerId  -  " + result.PlayerProfile.PlayerId);
        Debug.LogWarning("customeData  --  " + result.CustomData.ToString());

//result.PlayerProfile.Locations is NULL
        foreach (var item in result.PlayerProfile.Locations)
        {
            Debug.LogError("City: " + item.City + " Country: " + item.CountryCode);
        }
    }
Player Data
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

·
Gosen Gao avatar image
Gosen Gao answered

You can try the code below. I have tested it, and it works. BTW, there is a title setting – Data Collection, which can disable IP address collecting. You should also check this option.

PlayFabClientAPI.GetPlayerProfile(new GetPlayerProfileRequest
            {
                PlayFabId = result.PlayFabId,
                ProfileConstraints = new PlayerProfileViewConstraints
                {
                    ShowLocations = true
                }
            }, result => { 
                foreach(var Location in result.PlayerProfile.Locations)
                {
                    Debug.Log(Location.City);
                }
            }, error => {
                Debug.LogError(error.GenerateErrorReport());
            });
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.