Ready to Level-Up?

This just in! If your rusty iOS skills could use some refining, or if you're just starting out and you want to level-up fast, consider signing up for our upcoming iOS Screencasts

New from iOS Rocket Surgery Swift Video Tutorials: The rapidly evolving Apple-iOS ecosystem has just been thrown into tumult with the recent introduction of the Swift Programming Language. Are you ready to finally try iOS development? Are you needing to switch from Objective-C to Swift? Sign up today for our free video courses!
(By the dear folks at Swift Tutorial Videos, a sister company)

Tuesday, July 23, 2013

iOS UUID Replacement

So, you want to track your app install by giving it a unique id, huh?



Ok, easy peasy... we want to setup an iOS UUID Generator.

First, get OpenUDID from GitHub.

Second, write some code that looks like this:
NSString *openUDID = [OpenUDID value];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:openUDID forKey:@"unique_id"];    

What we've just done there is create a randomly generated UDID and stored it in our NSUserDefaults instance. Now, you can fetch it out at some later time, say, when making a remote request like this:

NSString *uniqueId = [defaults objectForKey:@"unique_id"];

I personally use this id to give me a warm fuzzy feeling that I can track multiple devices registered against the same account. You might be using the Push Notification registration ID for this, but in situations where you're not using Push, or when users won't enable push in your app, this is a nice way to track a single app install over multiple requests.

And of, course, the benefit is that the id stored in the preferences will go away when the app is uninstalled. This means that privacy is less of an issue from the user's perspective.

Now, aren't you glad Apple got rid of the UUID? Now, you're doing a service for yourself and giving your users some extra privacy. Everyone wins!





About Me

Easy NSDateFormatter Tool

Save yourself some time in formatting your NSDates to NSStrings, and use the Blind NSDate app, which you can download from iTunes. There's also a website where you can format your NSDates: http://www.blindnsdate.com

Popular Posts

Designed By Seo Blogger Templates