Last active
December 28, 2015 09:49
-
-
Save sag333ar/7482046 to your computer and use it in GitHub Desktop.
Get the UDID of the current iOS device.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString*)UDID { | |
NSString *uuidString = nil; | |
// get os version | |
NSUInteger currentOSVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] integerValue]; | |
if(currentOSVersion <= 5) { | |
if([[NSUserDefaults standardUserDefaults] valueForKey:@"udid"]) { | |
uuidString = [[NSUserDefaults standardDefaults] valueForKey:@"udid"]; | |
} else { | |
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault); | |
uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(NULL,uuidRef)); | |
CFRelease(uuidRef); | |
[[NSUserDefaults standardUserDefaults] setObject:uuidString ForKey:@"udid"]; | |
[[NSUserDefaults standardUserDefaults] synchronize]; | |
} | |
return uuidString; | |
} else { | |
return [UIDevice identifierForVendor]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment