question

My Game Studio avatar image
My Game Studio asked

Inconsistencies with SystemInfo.deviceUniqueIdentifier

Hello, due to the nature of Unity's SystemInfo.deviceUniqueIdentifier's being mutable under certain circumstances, is there another suggestion for making sure that you are persisting the player's data across all play sessions? Preferably without any layer of prompting the user for data, but if it comes down to that, what is the preferred method for that within the PlayFab framework?

10 |1200

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

brendan avatar image
brendan answered

The example quoted by Alberto is the correct code to use. You can find an example of this in our Login sample: https://github.com/PlayFab/Unity3d_Login_Example_Project/blob/8b59a9611f81b1c4c495caf703b22922bf27e0f4/Assets/PlayFabSamples/Login/Scripts/PlayFabLoginCalls.cs (in the GetDeviceId function).

Unfortunately, the problem described where an iOS user who uninstalls all games/apps which are under your developer ID, then re-installs one later getting a new Device ID, is specifically what their OS is designed to do - they generate a random ID for each developer on install, and forget that ID when the last of that developer's apps is removed. We provide a range of login options to help developers get the player back to their original account, including Facebook and Google login options, which are minimally invasive if the user has an account on either service. The username/password option is there as well, though that's a fairly high-friction way to get the player back to their account, and so won't work well for all titles.

Once you have the player back on their account, you can use the Unlink/Link API calls to update the account to the new iOS device ID you have available.

Note that if none of those are options, one thing to make sure you're aware of is the RestoreIOSPurchases method. This is the API call you'll need to use if you need to restore durable goods purchased on the previous PlayFab account by the user (dno't worry - this is secure, so a user can't submit a restore receipt from someone else's account).

10 |1200

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

Alberto Gomez avatar image
Alberto Gomez answered

I have the same question too. I have tried using UnityEngine.iOS.Device.vendorIdentifier, as you guys have in the tutorials, but it won't work. Everytime the player uninstalls and installs the game, a new device id is generated, thus using LoginWithIOSDeviceID creates a new player on playfab...

I didn't have problems with the Android version, in which I used this code (though I'm scared that this doesn't work in last Android versions):

AndroidJavaClass clsUnity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject objActivity = clsUnity.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject objResolver = objActivity.Call<AndroidJavaObject>("getContentResolver");
AndroidJavaClass clsSecure = new AndroidJavaClass("android.provider.Settings$Secure");
string android_id = clsSecure.CallStatic<string>("getString", objResolver, "android_id");
androidID = android_id;
10 |1200

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

Alberto Gomez avatar image
Alberto Gomez answered

Hi again! I bought this plugin and it does the work for iOS!

You should give it a try
https://www.assetstore.unity3d.com/en/#!/content/43083

10 |1200

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

brendan avatar image
brendan answered

Thanks for the link! The Keychain (https://developer.apple.com/library/ios/documentation/Security/Conceptual/keychainServConcepts/01introduction/introduction.html#//apple_ref/doc/uid/TP30000897-CH203-TP1) would also be a way to manage consistent identity, as you could generate a GUID, use LoginWithCustomId, and save the GUID in the Keychain for later re-use on sign-in.

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

FENG LI avatar image FENG LI commented ·

I don't know how to geneate GUID in Unity, how about I just save the SystemInfo.deviceUniqueIdentifier in KeyChain for later re-use on sign-in?

0 Likes 0 ·
brendan avatar image brendan FENG LI commented ·

Any unique identifier would work, yes.

0 Likes 0 ·
FENG LI avatar image FENG LI commented ·

Thanks for the reply.

0 Likes 0 ·

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.