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.
Answer by Sarah Zhang · Aug 29, 2019 at 06:55 AM
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.
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.
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.
Thanks a lot for the tip! This will be our second option if advertisingIdentifier proves to be not good enough.
Answer by talha-1 · Feb 10, 2020 at 02:27 PM
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.
Answer by peter-2 · Jun 23, 2020 at 04:28 PM
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!