你好 StackOverflow 成员 :) 我想知道是否可以通过调用网络服务发送 UDID 号码来验证我的应用程序的用户?
在我的数据库中,我会将 UDID 作为主键,并将可用信用数引用到该键。
苹果允许吗?如果是,我如何以编程方式获取 UDID?
最佳答案
可以获取到序列号但是我觉得不建议使用UDID
对于序列号,您可以使用此代码
- (NSString*)getSerialNumber
{
CFTypeRef serialNumberAsCFString;
io_service_t platformExpert = IOServiceGetMatchingService(
kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
if (platformExpert)
{
serialNumberAsCFString = IORegistryEntryCreateCFProperty(
platformExpert, CFSTR(kIOPlatformSerialNumberKey),
kCFAllocatorDefault, 0);
}
IOObjectRelease(platformExpert);
NSString *serial =
[[NSString alloc] initWithFormat:@"%@",serialNumberAsCFString];
return serial;
}
但是您可以尝试使用这行代码来获取 UDID,我不确定它是否会给出所需的结果。 Apple 可能会拒绝该应用,并且此 UDID 功能在较新版本的 iOS 中已弃用。
NSString *uid;
uid= [[UIDevice currentDevice] uniqueIdentifier];
NSLog(@"udid is %@",uid);
关于ios - 用于识别用户的 UDID 号码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15281861/