0

Hello StackOverflow members :) I wonder if it's possible to send the UDID number in order to authenticate an user of my app ,with a call to a web service?

In my database, I will have the UDID as a primary key and the number of availables credits referenced to this key.

Is it allowed by Apple ? And if it is, how can I get the UDID programmatically?

Obj-Swift
  • 2,802
  • 3
  • 29
  • 50
Seb
  • 545
  • 9
  • 29
  • 2
    "indentificate" is a fantastic word you just made up there. I love it. – Alex Wayne Mar 07 '13 at 21:16
  • check this http://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now – tkanzakic Mar 07 '13 at 21:17
  • @AlexWayne : I suggest this word to the english dictionary, I'm waiting for their acceptance ^^ – Seb Mar 07 '13 at 21:22
  • 1
    Apple has started rejecting apps that use the UDID (and it is deprecated in the API). Either use one of the replacement methods on `UUID` or (more likely based on your question's use-case) you need to use a `user ID/password` combination to login to your server. – Robotic Cat Mar 07 '13 at 21:22
  • I would advise against it considering a user of your app may purchase a new mobile device. – Jeremy Mar 07 '13 at 21:25
  • 1
    i would suggest using the hashed MAC address :).. very hard that you get rejected for that – Ultrakorne Mar 07 '13 at 21:59

1 Answers1

3

It is possible to get the serial number but I think it is not recommended to use UDID

for serial number you could use this code

- (NSString*)getSerialNumber
{
    CFTypeRef serialNumberAsCFString;
    io_service_t platformExpert = IOServiceGetMatchingService(
        kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
    if (platformExpert)
        {
            serialNumberAsCFString = IORegistryEntryCreateCFProperty(
                platformExpert, CFSTR(kIOPlatformSerialNumberKey), 
                kCFAllocatorDefault, 0);
        }
    IOObjectRelease(platformExpert);
    NSString *serial = 
        [[NSString alloc] initWithFormat:@"%@",serialNumberAsCFString];
    return serial;
}

Reference for the code

However you could try this line of code for getting the UDID, which I am not sure if it will give the required results. Apple may reject the app and this UDID feature is deprecated in the newer versions of iOS.

NSString *uid;
uid= [[UIDevice currentDevice] uniqueIdentifier];
NSLog(@"udid is %@",uid);
nsgulliver
  • 12,655
  • 23
  • 43
  • 64
  • Thanks for the code. I just want to know if it's allowed by Apple to send it ? – Seb Mar 07 '13 at 21:22
  • 2
    @Seb [this](http://stackoverflow.com/questions/9459188/has-anyone-had-their-ios-app-rejected-by-apple-for-using-the-devices-udid) will answer the question about rejection or acceptance, it is better idea to use serial number i suppose – nsgulliver Mar 07 '13 at 21:24
  • 3
    @Seb You are not *supposed* to use the UUID, and it will be removed eventually. Starting a new app, I would recommend against using the UUID like the second example here, unless there is an **extremely** good reason for it. – Mike D Mar 07 '13 at 21:25