UUID for app on iOS5 [duplicate]
Asked Answered
L

1

11

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.

Lees answered 18/10, 2011 at 6:56 Comment(7)
Why would a UUID from CFUUIDCreate, stored with NSUserDefaults, not satisfy your authentication use case ? Each installation would always send the same value (until it would get deleted and reinstalled). It may be annoying while developing, but a user doesn't delete his apps very often, does he ?Carthage
Also, why would the MAC change ? It can change on a PC where you can tweak it with some tool, but as long as you don't do that MACs never change.Carthage
@Carthage It is not a possible duplicate. I have read that post as well before I posted my own. You already answered your second comment in the comment itself. Next time the app gets installed I need the same UUID, not a new one for that installation. I do delete apps quite reguarlly, and I am also a user. However, this SO question is not about a users habits, regardless of what they are. My requirements are a UUID that is unique but the same every installation.Lees
@Carthage It does not, not if you don't want it to. But you, as a user, can change a MAC address if you want to. I am sorry to say it, but your arguments don't stick. I am looking for an answer, not someone that questions my requirements. Hope you can help me out with an answer though.Lees
I noticed that it's not a duplicate later on but can't "take it back". Also, I'm not questioning your requirements just for fun but to understand why the solutions you already know about aren't sufficient. I'm afraid that so far, it seems that the MAC is the only thing you can rely on. The MAC does not change on an iOS device unless you're on a jailbroken device with the user explicitly changing it (there's no way to change it on a non-jailbroken device I know of). Surely it isn't worth caring about the few people that do something strange as that.Carthage
Yes, I understand that and do appreciate it, but nevertheless I have already thought about the requirements. The big problem in this project of mine is that it has to do with payments, and when money is involved (even victive money) its always the few "unimportant" onces that are important. I see that flurry has statistics about seeing if a device is jailbroken or not, how can one do that?Lees
let us continue this discussion in chatCarthage
C
7

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.

Carthage answered 18/10, 2011 at 8:44 Comment(1)
As I mentioned in the chat, private libs is a bit no-no. Apple will not allow it. I'll have to use the Mac address. Thnx for you help!Lees

© 2022 - 2024 — McMap. All rights reserved.