# UUID (Universally Unique Identifier)

# Apple's IFA vs. IFV (Apple Identifier for Advertisers vs. Identifier for Vendors)

  • You can use the IFA for measuring ad clicks and the IFV for measuring app installs.
  • IFA has built-in privacy mechanisms that make it perfect for advertising. In contrast, the IFV is for developers to use internally to measure users who install their apps.
  • IFA (opens new window)

  • ASIdentifierManager class provides
    • **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.
    • IFV (opens new window)

    • 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 (opens new window).

        # Generating UUID

        # Random UUID

        # Swift

        func randomUUID() -> NSString{
            return NSUUID.UUID().UUIDString()

        # Objective-C

        + (NSString *)randomUUID {
            if(NSClassFromString(@"NSUUID")) { // only available in iOS >= 6.0
                return [[NSUUID UUID] UUIDString];
            CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
            CFStringRef cfuuid = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
            NSString *uuid = [((__bridge NSString *) cfuuid) copy];
            return uuid;

        # Identifier for vendor

        Within a single line, we can get an UUID like below:

        # Swift

        let UDIDString = UIDevice.currentDevice().identifierForVendor?.UUIDString

        # Objective-C

        NSString *UDIDString = [[[UIDevice currentDevice] identifierForVendor] UUIDString];

        The identifierForVendor is 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 (opens new window) about when this UUID changes.

        # Create UUID String for iOS devices

        Here we can create UUID String with in one line.

        Represents UUID strings, which can be used to uniquely identify types, interfaces, and other items.

        # Swift 3.0


        It is very useful for identify multiple devices with unique id.

        # Remarks

        To save the UUID we can use SSKeychainUtility (opens new window). Example can be found on Github page