question

talha-1 avatar image
talha-1 asked

How to fix creating a new user on iOS every time app is uninstalled and installed again

Hello,

We are making a game in Unity, and for login we are using PlayFabSettings.DeviceUniqueIdentifier (which redirects to SystemInfo.deviceUniqueIdentifier for iOS).

Everything is perfect on Android. A player can uninstall the app, install it again, and they will login with the same user they were using before.

But on iOS, every time the app is uninstalled and installed again, it creates a new user. I vividly remember that this was not the case at some point, we were able to always use the same Playfab users on our test devices.

Here is the piece of code that could be relavant. If someone wants more info just let me know:

var deviceId = PlayFabSettings.DeviceUniqueIdentifier;
switch (Application.platform)
{
    case RuntimePlatform.IPhonePlayer:
    {
        var request = new LoginWithIOSDeviceIDRequest { CreateAccount = true, TitleId = _titleId, DeviceId = deviceId };
        PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginSuccess, OnLoginFailure);
        break;
    }
    case RuntimePlatform.Android:
    {
        var request = new LoginWithAndroidDeviceIDRequest { CreateAccount = true, TitleId = _titleId, AndroidDeviceId = deviceId };
        PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnLoginSuccess, OnLoginFailure);
        break;
    }
    default:
    {
        var request = new LoginWithCustomIDRequest { CreateAccount = true, TitleId = _titleId, CustomId = deviceId };
        PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
        break;
    }
}

Are we doing anything wrong? How can we fix this?

The issue resembles this: https://community.playfab.com/questions/15006/player-account-changes-on-ios.html

But in this one it states that as long as there are apps installed from the same developer on this phone it should keep the same device ID. In our case, we have our other app from the same dev account installed on this phone, yet, uninstalling still makes it impossible to get the same account on Login.

Account Management
10 |1200

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

Sarah Zhang avatar image
Sarah Zhang answered

After researching, we found that Systeminfo.deviceUniqueIdentifier will not deliver the iOS Device's UDID. From the Unity side, a possible workaround is using Device.advertisingIdentifier to get the AdvertisingIdentifier. Be aware that the user can decide to change them in the iOS advertising Options. We refer to this thread from the Unity Community. You can also search such keywords on the Unity Community or Google for more info about how to get a unique identifier IOS in unity.

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.

talha-1 avatar image talha-1 commented ·

This worked! Thanks a lot Sarah. It's weird that SystemInfo.deviceUniqueIdentifier returns something that changes so easily. In theory, advertisingIdentifier seems much more secure, I'd be surprised if a lot of users actually went to settings and changed their advertisingIdentifier.

0 Likes 0 ·
brandon@uprootstudios.com avatar image brandon@uprootstudios.com talha-1 commented ·

We needed to rely on something that cannot be altered by the user, so we went with storing the initial UDID that the device provides on first install in the device keychain, and retrieve it from the keychain to login. Here's the open source keychain plugin for Unity that we're using: https://github.com/phamtanlong/unity-ios-keychain-plugin

If the application is uninstalled completely and then reinstalled, our app gets the initial UDID from the keychain and logs in to the initial account.

0 Likes 0 ·
talha-1 avatar image talha-1 brandon@uprootstudios.com commented ·

Thanks a lot for the tip! This will be our second option if advertisingIdentifier proves to be not good enough.

0 Likes 0 ·
Show more comments
talha-1 avatar image
talha-1 answered

An update on this in case anyone is using this as reference: advertisingIdentifier created a problem for us on some phones that didn't allow this information somehow, resulting in one shared Playfab account for all those accounts with ID 00000000-0000-0000-0000-000000000000. Might be an iOS bug or might be an intended weird feature. Obviously a huge issue, for now we ended up checking if the ID is zeros, if so use the deviceUniqueIdentifier instead (which still has the problem of resetting on uninstall). Another solution is what Brandon Phillips mentioned with the keychain tool.

10 |1200

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

peter-2 avatar image
peter-2 answered

Just a note, if you are seeing an Advertising ID come through from IOS devices, it is because they have switches on a Privacy setting in IOS. Look in the Privacy Settings menu, under Advertising, Limit Ad Tracking. Turning this on sends 00000000-0000-0000-0000-000000000000 all the time. Hope this helps!

,

Just a note, if you are seeing an Advertising ID come through from IOS devices, it is because they have switches on a Privacy setting in IOS. Look in the Privacy Settings menu, under Advertising, Limit Ad Tracking. Turning this on sends 00000000-0000-0000-0000-000000000000 all the time. Hope this helps!

10 |1200

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

Tuomas Karmakallio avatar image
Tuomas Karmakallio answered

Using advertisingIdentifier on iOS seems like you would have to then click the 'using IDFA' setting on submitting builds?

https://developer.apple.com/forums/thread/103552

10 |1200

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

Jon avatar image
Jon answered

I think for iOS you can use

https://docs.unity3d.com/ScriptReference/iOS.Device-vendorIdentifier.html

It should not be IDFA and therefore won't be zeroed out

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.