0

I'm currently working on a suite of iOS applications that will be using the same server for authentication. The server uses a UDID for device authentication. I'm aware that uniqueIdentifier is now deprecated, so I'm wondering what the best practice is for having a unique identifier across applications? (I know how to generate my own and store it in the keychain, but this will be application specific) I have seen postings about identifierForVendor and identifierForAdvertising

jscs
  • 63,694
  • 13
  • 151
  • 195
jrushing
  • 878
  • 1
  • 8
  • 11
  • Pls have a look at http://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now – nkongara Apr 17 '13 at 21:00

2 Answers2

1

The docs say:

[uniqueIdentifier is] deprecated in iOS 5.0. Use the identifierForVendor property of this class or the advertisingIdentifier property of the ASIdentifierManager class instead, as appropriate, or use the UUID method of the NSUUID class to create a UUID and write it to the user defaults database.

matt
  • 515,959
  • 87
  • 875
  • 1,141
1

As we know uniqueIdentifier is deprecated in iOS 5.0 so docs recommend you to use CFUUID

instead. You can get CFUUID using

CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
NSString *uuidString = (NSString *)CFUUIDCreateString(NULL,uuidRef);
CFRelease(uuidRef);

Please save the uuidString in user defaults or in other place because you can not generate the same uuidString again.

Hope it helps you.

Nishant Tyagi
  • 9,893
  • 3
  • 40
  • 61
  • Thanks yeah, I know how to create a new UUID string but if I'm not mistaken user defaults aren't accessible across applications, correct? So each application would have a different UUID which doesn't really fit for what I'm trying to accomplish in this situation. – jrushing Apr 17 '13 at 21:40
  • @JustinRushing Then why do you reject e.g. the keychain solution? – matt Apr 17 '13 at 22:48
  • You can store UUID in keychain if you need to access across many applications. This should not be the problem for you. – Nishant Tyagi Apr 17 '13 at 22:58
  • Oh, really? I never knew that. So say I make application A and application B, both in the app store. If I store a value in the keychain from application A, how would I go about accessing that value from application B? Aren't the applications sandboxed? I know that the keychain is a single entity but I thought that apps couldn't access other apps keystores. I've only worked with the KeychainItemWrapper class put out by apple. – jrushing Apr 18 '13 at 17:40