我的应用程序与iOS5和iOS6兼容.到现在为止我使用时没有问题:
NSString DeviceID = [[UIDevice currentDevice] uniqueIdentifier];
Run Code Online (Sandbox Code Playgroud)
现在使用iOS7并且uniqueIdentifier不再工作了,我改为:
NSString DeviceID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
Run Code Online (Sandbox Code Playgroud)
问题是,这对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
Run Code Online (Sandbox Code Playgroud)