我使用以下代码获取标识符
deviceName = [[UIDevice currentDevice]uniqueIdentifier];
Run Code Online (Sandbox Code Playgroud)
但我得到的警告uniqueIdentifier在ios5中已被弃用.
那么如何在ios5中获取标识符值?
J. *_*sta 18
您可以使用以下代码
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
// This will run if it is iOS6 or higher
return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else {
// This will run before iOS6 and you can use openUDID or other
// method to generate an identifier
}
Run Code Online (Sandbox Code Playgroud)
这样您就可以保持之前的最小要求.
此标识符对于来自一个供应商的所有应用程序是唯一的 如果您需要设备的唯一标识符,则需要使用:
if (!NSClassFromString(@"ASIdentifierManager")) {
// This will run before iOS6 and you can use openUDID, per example...
return [OpenUDID value];
}
return [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
Run Code Online (Sandbox Code Playgroud)
警告:如果设备是"空中"更新,iOS6上有一个报告"空"标识符的错误 - 更多信息
| 归档时间: |
|
| 查看次数: |
13169 次 |
| 最近记录: |