3

I just want to know what can be used and stored on server from an Apple device (iPod Touch, iPhone or iPad) to make unique identifier? such as IMEI or something... I just need something unique so that my app can do 'once from same device' validation.

thank you.

Saint Robson
  • 5,475
  • 18
  • 71
  • 118

4 Answers4

7

You can use NSUUID. However this changes, so you can implement it by calling it the first time the app is open and saving it.

    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"])
{
        //App has previously launched

}
else
{
    //First launch
    NSString *identifierString = [[NSUUID UUID] UUIDString];
    [[NSUserDefaults standardUserDefaults] setObject:identifierString forKey:@"uuidKey"];

    [[NSUserDefaults standardUserDefaults] synchronize];
}

Edit: for some more information and the options available to you, check out this great article.

Michael M
  • 1,034
  • 2
  • 8
  • 21
2

If you are running on iOS 6.0 or later, you can use identifierForVendor from UIDevice.

NSUUID*   pUUID;
UIDevice* pThisDvc;

pThisDvc = [UIDevice currentDevice];
if ( pThisDvc )
{
    pUUID = [pThisDvc identifierForVendor];
}
Jim Rhodes
  • 5,021
  • 4
  • 25
  • 38
  • Why do we have to check `if (pThisDvc)` ?? Are there any instances when `[UIDevice currentDevice]` does not return a valid object ? – n00bProgrammer Sep 26 '13 at 08:42
1

Consider having a look at this Open source initiative for a universal and persistent UDID solution for iOS

thatzprem
  • 4,697
  • 1
  • 33
  • 41
1
NSUUID* identifier = [[UIDevice currentDevice] identifierForVendor];

NSString* uniqueIdentifier = [identifier UUIDString];

This returns a unique identifier for the current device, that is unique to each app. Apple recommends using this for general purposes, and advertisingIdentifier for purposes of advertising.

When implementing a system for serving advertisements, use the value in the advertisingIdentifier property of the ASIdentifierManager class instead of this property. Use of that property requires you to follow the guidelines set forth in the class discussion for the proper use of that identifier. For more information, see ASIdentifierManager Class Reference.

... from here

n00bProgrammer
  • 4,261
  • 3
  • 32
  • 60