Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UUID for app on iOS5 [duplicate]

Possible Duplicate:
UIDevice uniqueIdentifier Deprecated - What To Do Now?

As I expect you are aware of, the uniqueIdentifier in UIDevice is deprecated in iOS5. What I am looking for a basically the same functionality for iOS5.

What I understand from the documentation is that apple wishes that we (developers) create our own UUID (using CFUUIDCreate I guess) and store it in the NSUserDefaults. This, however, makes me shiver a bit and does not at all feel save. Feels a bit pointless to have a UUID in this case.

The reason I need an UUID is because I send of a bunch information including UUID to my servers in the auth process and would like to be able to skip some steps if the server can "guess" whom the user is next time the app gets launched or re-installed or another app implements my library. CFUUIDCreate does not seem to help me with this.

I took a quick look at gekitz as well, but as I understand it, it bases it solely on the MAC address of the Ethernet "card" in the phone. This is not suitable since I have a vague feeling that the MAC address is changeable. The uniqueIdentifier in UIDevice was

An alphanumeric string unique to each device based on various hardware details.

Currenly I wrote this code, which retrieves a UUID. But as soon as I clean in XCode and re-install the app on the phone, I get a new UUID.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *UUID = @"";

if (![defaults valueForKey:@"UUID"])
{
    CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
    CFStringRef UUIDSRef = CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
    UUID = [NSString stringWithFormat:@"%@", UUIDSRef];

    [defaults setObject:UUID forKey:@"UUID"];
}
else {
    UUID = [defaults valueForKey:@"UUID"];
}

[deviceInformation setObject:UUID forKey:@"UUID"];

To sum it up, my question is the following:
Is there some solid way of creating an UUID that is based upon the device which is "hard" to tamper with and gives me as receiver a little something to depend and trust upon? This does not have to be based on the device, may be based on the app as a App UUID as long as its the same after a re-installation.

like image 760
Paul Peelen Avatar asked Oct 18 '11 06:10

Paul Peelen


1 Answers

So far, the MAC seems to be the only known "stable" way to identify a device.

Have a look at Erica Sadun's UIDevice(Hardware) category, you'll notice that the only useful thing for identification is the MAC.

She also has a UIDevice(IOKit_Extensions) category which does provide IMEI and serial number. However, IOKit is private API. Erica wrote:

As iPhone evangelist Matt Drance tweeted, "IOKit is not public on iPhone. Lack of headers and docs is rarely an oversight."

So using IOKit might get you rejected.

As far as I know there is no way for a user to change the MAC without jailbreaking the device (and then he can do anything he wants anyway). So my suggestion is to ignore the jailbreakers and simply use a UUID based on the MAC.

Warning! MAC address APIs will not work in iOS 7.

like image 118
DarkDust Avatar answered Sep 17 '22 15:09

DarkDust