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 )