Unique Identifier for both iOS 7 and for older iOS

I am using UnityEngine.SystemInfo.deviceUniqueIdentifier as a part of my encryption and decryption process of sensitive data.

It is my understanding (from reading this thread) that this value will change in iOS 7. For me it will mean that any upgraded device, will be treated as it is a new fresh installation.

Is there any other attribute in Unity I can use that will serve as a (relatively-) unique string and will be the same on iOS 7 and iOS 6 and below?

I have read some posts and answers that suggest saving the device ID in a PlayerPrefs variable, but I fail to understand how this solves the problem. If the ID is saved in prefs, it can be overwritten by anyone, and therefore not serving my purpose.

Found iPhone.vendorIdentifier - would that be an appropriate alternative, and working cross OS version? What will it return in pre iOS 6 devices?

The reason it is changing in os7 is to make tracking a device impossible so by nature there will be no way to do this by design. Though using the unique device ID as part of encryption is dubiously more secure anyhow. Only thing you can do is change it to a user provided password.

  • New way below using identifierForVendor

  • Note Unity 4 has ‘iPhone.vendorIdentifier’ built in, but below will work for earlier Unity versions

The vendorIdentifier:
“The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes”

Getting UIDevice.identifierForVendor to Unity:

Open Xcode and open the file ‘UnityAppController.mm’ ( used to be called just AppController.mm in older Unity versions I think )

inside one of the methods/functions ( not sure which is best ) say inside of “- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

you can add a call to Unity using UnitySendMessage:

UnitySendMessage(“SomeClass”, “SomeMethod”,“stringMessageYouAreSending”);

Above would call this class/method in Unity ( remember to add it to an object in your scene ):

public class SomeClass : MonoBehaviour {
	public void SomeMethod( string message ) {

So to get this identifierForvendor insert this code into the UnityAppController.mm inside the method:
“- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions”

if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
        // This is will run if it is iOS6
        NSString *uniqueString = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
        UnitySendMessage("SomeClass", "SomeMethod",[uniqueString cStringUsingEncoding:NSUTF8StringEncoding] );
} else {
        // This is will run before iOS6 and you can insert code here to use openUDID or other method to generate an identifier

( not sure the string conversion here ( cStringUsingEncoding:NSUTF8StringEncoding ) is the best way, but it works )

What will it return in pre iOS 6

Empty string (at least on iOS 5.1.1).