我的应用程序与iOS5和iOS6兼容。 到目前为止,我使用没有问题的是:
NSString DeviceID = [[UIDevice currentDevice] uniqueIdentifier];
现在iOS7以后,uniqueIdentifier已经不能使用了,我改成了:
NSString DeviceID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
问题是,这种方法不适用于iOS5。
如何实现与iOS5的向后兼容?
我尝试了这个方法,但没有成功:
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
// iOS 6.0 or later
NSString DeviceID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
#else
// iOS 5.X or earlier
NSString DeviceID = [[UIDevice currentDevice] uniqueIdentifier];
#endif