Current location - Trademark Inquiry Complete Network - Trademark registration - How to get the unique identifier in the ios program
How to get the unique identifier in the ios program

The way to generate a unique identifier for an iOS device is to use the Media Access Control (MAC) address of the iOS device. A MAC address is a unique number that is assigned to a network adapter at the physical network level. Apple has other names for this address, such as Hardware Address or Wifi Address, which all refer to the same thing.

Many projects and frameworks use this method to generate unique device IDs. For example, ODIN. However, Apple doesn't want anyone to be able to identify users by their MAC address, so if you query the MAC address on iOS 7, it will now just return 02:00:00:00:00:00.

Now Apple clearly states that you should use -[UIDevice identifierForVendor] or -[ASIdentifierManager advertisingIdentifier] as the unique identifier for your framework and application. Frankly speaking, it is not that difficult to deal with these changes, see the following code snippet:

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

NSString *identifierForAdvertising = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];

Each method is adapted to a specific usage:

identifierForVendor is a unique value for the vendor, and That is to say, apps published by the same company will have the same identifier when running on the same device. However, if the user deletes and then reinstalls the vendor's app, the identifier will be inconsistent.

The advertisingIdentifier will return the same value to all software vendors on this device, so it can only be used for advertising. This value will change due to many situations, such as when the user initializes the device.