question

Dominic Hamelin-Blais avatar image
Dominic Hamelin-Blais asked

Using ProfileConstraints + ShowLocations only returns the City

Hi,

I have activated the Locations under the Client Profile Options.

Upon a login Android/iOSDeviceId I'm using GetPlayerProfile=true, and ShowLocations=true

But in the response, I only see the city:

"Locations":[{"City":"MY-CITY-HERE"}]

Is there a way to get the country code with this?

(Title ID: C986)

apis
10 |1200

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

Neils Shi avatar image
Neils Shi answered

You can try my test code to see if the problem persists.

 public void Start()
   {
     var request = new LoginWithCustomIDRequest
       {
           CustomId = "TestLocation",
           CreateAccount = true,
           InfoRequestParameters = new GetPlayerCombinedInfoRequestParams() { 
           GetPlayerProfile = true, 
           ProfileConstraints =new PlayerProfileViewConstraints() { ShowLocations = true}
           }
       };
       PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
    }
    
  private void OnLoginSuccess(LoginResult result)
    {
       Debug.Log(result.InfoResultPayload.PlayerProfile.Locations[0].CountryCode.ToString());
       Debug.Log("login sucessfully");
     }
    
   private void OnLoginFailure(PlayFabError error)
   {
       Debug.LogWarning("Something went wrong ");
       Debug.LogError("Here's some debug information:");
       Debug.LogError(error.GenerateErrorReport());
   }
1 comment
10 |1200

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

Dominic Hamelin-Blais avatar image Dominic Hamelin-Blais commented ·

It crashes on the first try. PlayerProfile seems to be null on account creation, but it's working fine afterward.

So I have learned that JsonUtility.ToJson ignore nullable friend :/

Sorry for the time lost, and thank you for the help.

0 Likes 0 ·
Neils Shi avatar image
Neils Shi answered

I created a test account under your title and used API LoginWithCustomID(the CustomId is "test", you can delete it later). Then I was able to get the player's country (Also, I only set GetPlayerProfile and ShowLocations to true).

 "Locations": [
                     {
                         "ContinentCode": "AS",
                         "CountryCode": "CN",
                         "Latitude": 34.7732,
                         "Longitude": 113.722
                     }
                 ]

This seems to an Android and Apple devices' permission problem, you can seek help from Android/Apple Professional technicians.

10 |1200

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

Dominic Hamelin-Blais avatar image
Dominic Hamelin-Blais answered

Hi,

Using the same iOS device, I have look at the Player's PlayStream, and in the player_logged_in event I do see my CountryCode. And in the Player's overview, I do see my Country too. So I don't think that it's related to a device permission.

 {
     "EventName": "player_logged_in",
     "Platform": "IOSDevice",
     "PlatformUserId": "D165B046-C5B7-40FE-9B4D-4813FD7EDE74-2",
     "PlatformUserName": null,
     "Location": {
         "ContinentCode": "NA",
         "CountryCode": "CA",
         "City": "*edited",
         "Latitude": *edited,
         "Longitude":*edited
     },

Also in the Cloud Script I have that manage the player's country for iOS and Android and it works fine (with server.GetPlayerCombinedInfo) It really seems to be an issue with the Login

5 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.

Neils Shi avatar image Neils Shi commented ·

Have you tried using API loginwithCustomID? Will it succeed in getting CountryCode?

0 Likes 0 ·
Dominic Hamelin-Blais avatar image Dominic Hamelin-Blais Neils Shi commented ·

I have tried LoginWithCustomID, but I'm having the same result (only the city name) - also using minimal settings (GetPlayerProfile and ShowLocations to true)

I have the same result in the Unity Editor, and also same result in a different city (different private WiFi) also same if I use my phone's LTE network.

0 Likes 0 ·
Neils Shi avatar image Neils Shi Dominic Hamelin-Blais commented ·

Is the SDK you use based on Unity ?which version is it? Also, you can provide your unity code (login request body and response) for us to do further research.

0 Likes 0 ·
Show more comments
Dominic Hamelin-Blais avatar image
Dominic Hamelin-Blais answered

Here's the response I got:

Result: {"EntityToken":{"Entity":{"Id":"294E987F036AD10C","Type":"title_player_account"},"EntityToken":"NHxFS2Fvc1dGWk5TUXpIY1hZNlhQendHWVBadTlwbkE1TXlUOGJobGJuYiswPXx7ImkiOiIyMDIzLTAyLTI4VDE0OjU5OjUyWiIsImlkcCI6IkN1c3RvbSIsImUiOiIyMDIzLTAzLTAxVDE0OjU5OjUyWiIsImZpIjoiMjAyMy0wMi0yOFQxNDo1OTo1MloiLCJ0aWQiOiJjZGFwQkRkelA2MCIsImlkaSI6InRlc3QiLCJoIjoiQ0JGQTI0Q0EyNzUzNkFEMyIsImVjIjoidGl0bGVfcGxheWVyX2FjY291bnQhNDUzRjQ5MzI0MDdDNzA4NC9DOTg2LzdFQURDQkNEOUJEMEM5MDIvMjk0RTk4N0YwMzZBRDEwQy8iLCJlaSI6IjI5NEU5ODdGMDM2QUQxMEMiLCJldCI6InRpdGxlX3BsYXllcl9hY2NvdW50In0="},"InfoResultPayload":{"AccountInfo":{"AndroidDeviceInfo":{"AndroidDeviceId":""},"AppleAccountInfo":{"AppleSubjectId":""},"CustomIdInfo":{"CustomId":""},"FacebookInfo":{"FacebookId":"","FullName":""},"FacebookInstantGamesIdInfo":{"FacebookInstantGamesId":""},"GameCenterInfo":{"GameCenterId":""},"GoogleInfo":{"GoogleEmail":"","GoogleGender":"","GoogleId":"","GoogleLocale":"","GoogleName":""},"GooglePlayGamesInfo":{"GooglePlayGamesPlayerAvatarImageUrl":"","GooglePlayGamesPlayerDisplayName":"","GooglePlayGamesPlayerId":""},"IosDeviceInfo":{"IosDeviceId":""},"KongregateInfo":{"KongregateId":"","KongregateName":""},"NintendoSwitchAccountInfo":{"NintendoSwitchAccountSubjectId":""},"NintendoSwitchDeviceIdInfo":{"NintendoSwitchDeviceId":""},"OpenIdInfo":[],"PlayFabId":"","PrivateInfo":{"Email":""},"PsnInfo":{"PsnAccountId":"","PsnOnlineId":""},"SteamInfo":{"SteamCountry":"","SteamId":"","SteamName":""},"TitleInfo":{"AvatarUrl":"","DisplayName":"","TitlePlayerAccount":{"Id":"","Type":""}},"TwitchInfo":{"TwitchId":"","TwitchUserName":""},"Username":"","XboxInfo":{"XboxUserId":"","XboxUserSandbox":""}},"CharacterInventories":[],"CharacterList":[],"PlayerProfile":{"AdCampaignAttributions":[],"AvatarUrl":"","ContactEmailAddresses":[],"DisplayName":"","ExperimentVariants":[],"LinkedAccounts":[],"Locations":[{"City":"Magog"}],"Memberships":[],"PlayerId":"7EADCBCD9BD0C902","PublisherId":"453F4932407C7084","PushNotificationRegistrations":[],"Statistics":[],"Tags":[],"TitleId":"C986","ValuesToDate":[]},"PlayerStatistics":[],"UserDataVersion":0,"UserInventory":[],"UserReadOnlyDataVersion":0},"NewlyCreated":false,"PlayFabId":"7EADCBCD9BD0C902","SessionTicket":"7EADCBCD9BD0C902-453F4932407C7084-294E987F036AD10C-C986-8DB199C71FFB01F-bMpJZ6jnzi8pNoW9/ZBbFQVSQ4ZMLBzUPm3C0YjBRZM=","SettingsForUser":{"GatherDeviceInfo":false,"GatherFocusInfo":false,"NeedsAttribution":false},"TreatmentAssignment":{"Variables":[],"Variants":[]}} UnityEngine.Debug:Log (object) PlayfabIdentityAPI/<>c:b_7_0 (PlayFab.ClientModels.LoginResult) (at Assets/Scripts/Cloud/Playfab/API/PlayfabIdentityAPI.cs:151) PlayFab.Internal.PlayFabHttp/<>c_DisplayClass23_0`1:<MakeApiCall>b1 () (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabHTTP.cs:215) PlayFab.Internal.PlayFabUnityHttp:OnResponse (string,PlayFab.Internal.CallRequestContainer) (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:216) PlayFab.Internal.PlayFabUnityHttp/d_13:MoveNext () (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:168) UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/Coroutines.cs:17)

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.