Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

identifierForVendor and iOS6

The identifierForVendor require iOS6, so if my app currently supporting iOS4 and therefore I can't use it since my updates should always meet my app's previous min. requirement?

like image 459
Ryan Avatar asked Sep 20 '12 06:09

Ryan


People also ask

What is identifierForVendor?

An alphanumeric string that uniquely identifies a device to the app's vendor.

Is identifierForVendor unique?

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 about when this UUID changes.

What is an IDFV?

The definition of IDFV? The Identifier for Vendors (IDFV) is a code assigned to all apps by one developer and is shared across all apps by that developer on your device. The value of the IDFV is the same for apps from the same developer running on the same device.


2 Answers

You can use this:

NSString *udid;

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0"))
    udid = [UIDevice currentDevice].identifierForVendor.UUIDString;
else
    udid = [UIDevice currentDevice].uniqueIdentifier;

with pre processor code:

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
like image 64
Naka Avatar answered Oct 04 '22 02:10

Naka


You don't need preprocessor macros for this, you should check if it response, like this:

if ([[UIDevice currentDevice]respondsToSelector:@selector(identifierForVendor)]) {
    return [UIDevice currentDevice].identifierForVendor.UUIDString;
}else{
    // return [UIDevice currentDevice]. uniqueIdentifier
    return [[UIDevice currentDevice] performSelector:@selector(uniqueIdentifier)];
}
like image 29
Laszlo Avatar answered Oct 04 '22 02:10

Laszlo