4

I'm developing a native iOS app and I`m kind of newbie both to objective-C and apple device development.

In my app I need to identify the user by an unique way. I think that the best solution would be to obtain current Apple ID and store it in online database for my purposes. The only catch is that the user can change it. So, I`m thinking Apple has to have another identifier to uniquely distinguish the actual accounts.

Is there any way I can get that one? Something I missed? Some class?

Thanks in advance... Pete

Petr Mánek
  • 1,046
  • 1
  • 9
  • 24
  • For what purpose will you be identifying the user? This will guide the best answer, as there are a multitude of ways of doing so. You can identify *the device* using its hardware identifier, if you're making a game, you could use Game Center account integration to identify the player. You've identified the problem with using an Apple ID , namely that one can use an iOS device without one, or change it. – Dan J Dec 25 '11 at 21:26
  • It`s a newspaper app and I need to grant a free online subscription to users who have had already purchased the print subscription. My concept is that I`ll bind users to the customers (It`s like restoring a zero-priced in-app purchase). – Petr Mánek Dec 25 '11 at 21:55

3 Answers3

12

All IOS devices have and Unique identifier UDID, wich is accesible through:

[[UIDevice currentDevice] uniqueIdentifier]

But this is discouraged by Apple and some apps are getting rejected by using this, basically because apple doesn't want you to track or treat devices as unique, because you can sell it or swap it with another person.

What you can do is to create a UUID which is a unique identifier and store it in the key chain, which means that this uniqueID will remain in the phone even if the app is deleted, it will only disappear when the you do a factory reset, which is what apple wants.

Another solution is to use external libraries that will generate uniqueID on a device basis like openUDID or UIDevice-with-UniqueIdentifier-for-iOS-5

Hope this helps!

Ecarrion
  • 4,940
  • 1
  • 33
  • 44
2

[[UIDevice currentDevice] uniqueIdentifier] is now deprecated.

You should use this instead:

UIDevice *device = [UIDevice currentDevice];
NSUUID *uniqueIdentifier = [device identifierForVendor];

UIDevice Class Reference

Alexandre Lins
  • 306
  • 1
  • 2
  • 10
  • identifierForVendor is not a trustable unique identifier because it does change in some circumstances. The only really trustable unique identifier is the playerID property in Game Center, but unfortunately it is only available for games. – Heitor Nov 09 '15 at 06:37
2

There is no way to get a unique user identifier (except potentially by politely asking the user for an optional and unverified response). Apple's privacy policy looks like it doesn't allow them to expose identify info for an app user in any manner.

The iOS device UDID is not only deprecated by Apple, but has little to do with the user (as the device could have changed owners, and a single user can have multiple devices all with different UDIDs).

hotpaw2
  • 70,107
  • 14
  • 90
  • 153