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?
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;
}
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);