question

Prabin Gurung avatar image
Prabin Gurung asked

Unable to fetch User Geo Location!

I am new in PlayFab. I try to get user geo location. But I got error. And I really don't know how its work.

Here is my code.

string x;

private void Start()

{

getplayerlocation();

}

public void getplayerlocation()

{

PlayFabClientAPI.GetPlayerCombinedInfo(new GetPlayerCombinedInfoRequest()

{

PlayFabId = PlayerPrefs.GetString("playfabid"),

InfoRequestParameters = new GetPlayerCombinedInfoRequestParams { ProfileConstraints = new PlayerProfileViewConstraints { ShowLocations = true } },

}, onsuccess, onerror);

}

void onsuccess(GetPlayerCombinedInfoResult result)

{

List<LocationModel> a = result.InfoResultPayload.PlayerProfile.Locations;

foreach (var b in a)

{

x = b.CountryCode.ToString();

}

Debug.Log(x);

}

void onerror(PlayFabError error)

{

Debug.LogError(error.GenerateErrorReport());

}

This is the error

error-console.png (13.6 KiB)
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

·
Prabin Gurung avatar image
Prabin Gurung answered

After few hours of research, finally I got my answer which is very simple. I forgot to include "GetPlayerProfile = true" in InfoRequestParameters.

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.