question

Kim Strasser avatar image
Kim Strasser asked

How can I get the players country setting in the client application?

The player should see the name of his country in his application after he logged in his PlayFab account.

What is the players country setting in Game Manager? Is this the country where he was when he logged in the last time? What happens to the country setting in Game Manager when the player logs in his PlayFab account while he is on holidays in Germany? Will the country setting change to Germany?

How can I get the players country setting in the client application? What API call should I use?

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

·
Citrus Yan avatar image
Citrus Yan answered

Hi Kim,

You can call GetPlayerPofile API to get player’s country setting, also note that the profile only contains the last location(according to last login). Therefore, if the player logs in Germany, the country info received will be Germany. By the way, you might also need to go to Client Profile Options under Settings and choose what parts of a player's profile are available to the client, including location. Let me know if you have any further questions, thanks.

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.

Kim Strasser avatar image Kim Strasser commented ·

1)What happens if the player uses a VPN? Will his profile country setting change if he uses a VPN server in another country?

2)Is it possible that the player can choose his country in a list of countries? His choice(for example Germany) would be saved in his PlayFab profile and the country would not be changed if he logs in in another country. His PlayFab profile country would always be Germany, even if he is on holidays in another country. Only the player himself could change the country manually in his profile.

Is it possible to do that with PlayFab?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Kim Strasser commented ·

Hi Kim,

>> What happens if the player uses a VPN? Will his profile country setting change if he uses a VPN server in another country?

Yes, his profile country setting will probably change if he uses a VPN server in another country since PlayFab identifies the user’s location according to the IP addresses.

>> Is it possible that the player can choose his country in a list of countries?

Yes, it is, although I can’t find any API that can directly make changes to PlayerProfile. The easiest way to do this would be saving the player’s country setting data in PlayerData using UpdateUserData. And, a more secure and recommended way would be writing PlayerProfile(country info, tel, or any other potential PII(personal identifying information)) in the player’s title_player_account entity. You can use SetProfilePolicy to control access of entities. Here is a tutorial for you to get started:

https://docs.microsoft.com/en-us/gaming/playfab/features/data/playerdata/entity-objects

0 Likes 0 ·
Kim Strasser avatar image Kim Strasser Citrus Yan commented ·

Thanx. I think I will use UpdateUserData because the country is public in my application and all players can see the country of another player in the leaderboard.

I have question about PlayerProfile. Will "result.Result.PlayerProfile.Locations[0].ToString();" always return the last location where a player logged in? For example, a player is logged in in Germany, after that he logs in in Switzerland. Will Locations[0] return Switzerland?

string PlayerCurrentCountry = "";

private async Task PlayerProfile()
{
    var result = await PlayFabClientAPI.GetPlayerProfileAsync(new GetPlayerProfileRequest()
    {
        PlayFabId = PlayerPlayFabID,
        ProfileConstraints = new PlayerProfileViewConstraints
        {
            ShowDisplayName = true,
            ShowCreated = true,
            ShowLastLogin = true,
            ShowAvatarUrl = true,
            ShowLocations = true
        }
    });

    if (result.Error != null)
        Console.WriteLine(result.Error.GenerateErrorReport());
    else
        PlayerCurrentCountry = result.Result.PlayerProfile.Locations[0].ToString();
            
}
0 Likes 0 ·
Show more comments

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.