UUID (Universally Unique Identifier)
Apple’s IFA vs. IFV (Apple Identifier for Advertisers vs. Identifier for Vendors)
Section titled “Apple’s IFA vs. IFV (Apple Identifier for Advertisers vs. Identifier for Vendors)”- **advertisingIdentifier: UUID**: An alphanumeric string unique to each device, used only for serving advertisements.
- **isAdvertisingTrackingEnabled**: A Boolean value that indicates whether the user has limited ad tracking.
- ASIdentifierManager class provides
-
- **identifierForVendor: UUID**: An alphanumeric string that uniquely identifies a device to the app’s vendor.
Find your device IFA and IFV here.
Generating UUID
Section titled “Generating UUID”Random UUID
Section titled “Random UUID”func randomUUID() -> NSString{return NSUUID.UUID().UUIDString()}Objective-C
Section titled “Objective-C”+ (NSString *)randomUUID {if(NSClassFromString(@"NSUUID")) { // only available in iOS >= 6.0return [[NSUUID UUID] UUIDString];}CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);CFStringRef cfuuid = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);CFRelease(uuidRef);NSString *uuid = [((__bridge NSString *) cfuuid) copy];CFRelease(cfuuid);return uuid;}Identifier for vendor
Section titled “Identifier for vendor”Within a single line, we can get an UUID like below:
let UDIDString = UIDevice.currentDevice().identifierForVendor?.UUIDStringObjective-C
Section titled “Objective-C”NSString *UDIDString = [[[UIDevice currentDevice] identifierForVendor] UUIDString];The
identifierForVendoris an unique identifier that stays the same for every app of a single vendor on a single device, unless all of the vendor’s apps are deleted from this device. See Apple’s documentation about when thisUUIDchanges.Create UUID String for iOS devices
Section titled “Create UUID String for iOS devices”Here we can create
UUID Stringwith in one line.Represents UUID strings, which can be used to uniquely identify types, interfaces, and other items.
Swift 3.0
Section titled “Swift 3.0”print(UUID().uuidString)It is very useful for identify multiple devices with unique id.
Remarks
Section titled “Remarks”To save the UUID we can use SSKeychainUtility. Example can be found on Github page