Tuesday, September 25, 2012

iOS - UDID replacement

Apple deprecated accessing the device identifier and hear that they going to reject apps which using the UDID

Our application is using the UDID to uniquely represent a user per application.

And we need to identify the user even if the user removes the application and install it again.


-------------------------------
The following is our replacement of UDID

 - (NSString *)getUUID
{
    KeychainItemWrapper  *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"mydeviceudid" serviceName:@"myservice" accessGroup:nil];
    NSString *newuuid = [wrapper objectForKey:(id)kSecAttrAccount]   
    if(newuuid == nil){
          CFUUIDRef theUUID = CFUUIDCreate(NULL);
         CFStringRef newcfuuid = CFUUIDCreateString(NULL, theUUID);
          CFRelease(theUUID);
         newuuid = [(NSString *)newcfuuid autorelease];
          [wrapper setObject:newuuid forKey:(id)kSecAttrAccount];
     }
    return newuuid;
 }
 


 references : http://stackoverflow.com/questions/427180/how-to-create-a-guid-uuid-using-the-iphone-sdk

No comments:

Post a Comment