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?
An alphanumeric string that uniquely identifies a device to the app's vendor.
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.
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.
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)
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)];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With