【发布时间】:2013-09-17 04:25:18
【问题描述】:
我的应用与 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
【问题讨论】:
-
openUDID 可能是您的合适替代品吗?
-
openUDID 是错误的答案。 blog.appsfire.com/…
-
您不能为此使用编译时指令,您需要运行时检查。
标签: ios objective-c uniqueidentifier