I'm writting an application for iphone, which communicates with my server using REST. The main problem is, I need to identify user somehow. Not so long ago, we were allowed to use UDID, but now its not allowed anymore. So what should I use instead? I need some kind of identifier on iphone, so user will delete application, install it again, and he will get same id.
UUID (Universally Unique Identifier): A sequence of 128 bits that can guarantee uniqueness across space and time, defined by RFC 4122. UDID (Unique Device Identifier): A sequence of 40 hexadecimal characters that uniquely identify an iOS device (the device's Social Security Number, if you will).
You can't change the UUID of your iPhone. But Yes, you certainly can generate an alternative UUID. A guy Kind guy gekitz wrote a category on UIDevice which will generate some kind of UDID based on device mac-address and bundle identifier.
How to Find Your iPhone and iPad's UUID. Connect your iPhone or iPad to your computer, and then open iTunes. Click the device icon at the top. Your device's UUID is hidden by default—click “Serial Number” and it will change to display your UUID.
I used CFUUIDCreate()
to create a UUID:
+ (NSString *)GetUUID { CFUUIDRef theUUID = CFUUIDCreate(NULL); CFStringRef string = CFUUIDCreateString(NULL, theUUID); CFRelease(theUUID); return [(NSString *)string autorelease]; }
Then set the above UUID to my NSString:
NSString *UUID = [nameofclasswhereGetUUIDclassmethodresides UUID];
I then stored that UUID to the Keychain using SSKeyChain
To set the UUID with SSKeyChain:
[SSKeychain setPassword:UUID forService:@"com.yourapp.yourcompany" account:@"user"];
To Retrieve it:
NSString *retrieveuuid = [SSKeychain passwordForService:@"com.yourapp.yourcompany" account:@"user"];
When you set the UUID to the Keychain, it will persist even if the user completely uninstalls the App and then installs it again.
To make sure ALL devices have the same UUID in the Keychain.
You now have a Unique Identifier that is persistent and shared/synced with all devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With