Created
February 8, 2012 21:12
-
-
Save jagbolanos/1773924 to your computer and use it in GitHub Desktop.
Create a UDID for the Device
This file contains hidden or 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
| /* | |
| UNIQUE IDENTIFIER | |
| */ | |
| + (NSString*) deviceIdentifier { | |
| NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
| NSString *deviceId = [defaults objectForKey:DEVICE_ID_KEY]; | |
| if (!deviceId) { | |
| //Create unique ID | |
| CFUUIDRef newUniqueId = CFUUIDCreate(kCFAllocatorDefault); | |
| CFStringRef newUniqueIdString = CFUUIDCreateString(kCFAllocatorDefault, newUniqueId); | |
| deviceId = [NSString stringWithFormat:@"%@",(NSString *)newUniqueIdString]; | |
| CFRelease(newUniqueId); | |
| CFRelease(newUniqueIdString); | |
| //deviceId = [self getMacAddress]; | |
| //Save it | |
| [defaults setObject:deviceId forKey:DEVICE_ID_KEY]; | |
| [defaults synchronize]; | |
| } | |
| return deviceId; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment