question

sathyaraj avatar image
sathyaraj asked

LoginWithCustomID creates new user every time in ios. [works fine in editor]

Following code creates new user every time in ios devices. The same code works fine in other titles and in editor and android phones.
 
TitleID: D37E

        GetPlayerCombinedInfoRequestParams paramRequest = new GetPlayerCombinedInfoRequestParams();
        paramRequest.GetUserAccountInfo = true;
        paramRequest.GetPlayerProfile = true;
        paramRequest.GetUserVirtualCurrency = true;
        paramRequest.GetTitleData = true;
        paramRequest.GetUserData = true;
        paramRequest.GetPlayerStatistics = true;


        PlayerProfileViewConstraints profileConstraints = new PlayerProfileViewConstraints() { ShowAvatarUrl = true, ShowDisplayName = true, ShowLocations = true };
        paramRequest.ProfileConstraints = profileConstraints;


        //trim deviceUniqueIdentifier to 30. or else playfab throws an error
        string deviceUniqueIdentifier = SystemInfo.deviceUniqueIdentifier;
        if (deviceUniqueIdentifier.Length > 30) deviceUniqueIdentifier = deviceUniqueIdentifier.Substring(0, 30);


        LoginWithCustomIDRequest request = new LoginWithCustomIDRequest()
        {
            TitleId = GameSkinData.gameSkin.currentGameData.playfabID,
            CreateAccount = true,
            InfoRequestParameters = paramRequest,
            CustomId = deviceUniqueIdentifier
        };


        PlayFabClientAPI.LoginWithCustomID(request, (result) =>
        {
            PlayerProfile.playFabID = result.PlayFabId;            
            if (onLoginEvent != null)
                onLoginEvent(true, LoginType.Guest, result.NewlyCreated, null);           
        },
        (error) =>
        {
           LogEvent(GameEvents.GameError, new EventBody("ShowLoadingScreenError", error.ErrorMessage));
        });
10 |1200

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

Seth Du avatar image
Seth Du answered

According to your code, it seems LoginWithCustomID is the only login API and if there are new accounts created all the time, the only reason is deviceUniqueIdentifier you have defined is different every time.

According to my experience, every time your app is installed, Apple will generate a new one and it will be deleted when the app is deleted. It is also determined by the distribution method of your app. Please also refer to: https://community.playfab.com/questions/14538/unity-ios-device-unique-identifier.html

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

sathyaraj avatar image sathyaraj commented ·

That means I can update the app to the app-store without worrying about current users losing their data! because for them it should basically give the same old uniqueID. Please correct me if I am wrong.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ sathyaraj commented ·

I think the idea is correct. However, I cannot guarantee it because I am not expert on Apple App development and you may need to confirm it from Apple developer community.

In terms of PlayFab side, Custom ID definitely cannot guarantee the safety of player accounts, and that's why we highly recommend using recoverable login identity. During the recent months, PlayFab have supported LoginWithApple API, which is a much better login method for iOS users.

Please also refer to the best practice of login: https://docs.microsoft.com/en-us/gaming/playfab/features/authentication/login/login-basics-best-practices

1 Like 1 ·
sathyaraj avatar image
sathyaraj answered

[Edit]

calling SystemInfo.deviceUniqueIdentifier gives following results
on first time install: 2BA21064-6018-4820-A7DB-34E68BB3C2B0
on second time install: 8FFF4A85-4C0D-472F-8D07-3E3A43642960

Anyone else facing this issue in ios

I am using Unity 2019.4.3f1

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.