Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Alternative iOS device unique identifier
#import <UIKit/UIKit.h>
@interface UIDevice (HostUUID)
- (NSString *) xcd_uniqueIdentifier;
@end
#import "UIDevice+HostUUID.h"
@implementation UIDevice (HostUUID)
- (NSString *) xcd_uniqueIdentifier
{
CFUUIDBytes uuidBytes;
gethostuuid((unsigned char *)&uuidBytes, &(const struct timespec){0, 0});
CFUUIDRef uuid = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, uuidBytes);
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuid);
CFRelease(uuid);
return [CFBridgingRelease(uuidString) lowercaseString];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment