2013-03-07 61 views
0

Hello StackOverflow成员:) 我想知道是否可以通过调用Web服务来发送UDID号码以验证我的应用的用户?用于标识用户的UDID号码

在我的数据库中,我将UDID作为主键以及引用此密钥的可用积分数。

苹果允许吗?如果是这样,我怎样才能以编程方式获得UDID?

+2

“indentificate”是一个很棒的词,你刚刚在那里制作。我喜欢它。 – 2013-03-07 21:16:25

+0

检查此问题http://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now – tkanzakic 2013-03-07 21:17:04

+0

@AlexWayne:我向英文字典建议这个词,我正在等待他们的接受^^ – Seb 2013-03-07 21:22:19

回答

3

这是可能得到的序列号,但我认为这是不推荐使用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; 
} 

Reference for the code

但是你可以尝试这行代码获取UDID,我不确定它是否会给出所需的结果。 Apple可能会拒绝该应用程序,并且此更新版本的iOS中不推荐使用此UDID功能。

NSString *uid; 
uid= [[UIDevice currentDevice] uniqueIdentifier]; 
NSLog(@"udid is %@",uid); 
+0

感谢您的代码。我只想知道Apple是否允许发送它? – Seb 2013-03-07 21:22:59

+2

@Seb [this](http://stackoverflow.com/questions/9459188/has-anyone-had-their-ios-app-rejected-by-apple-for-using-the-devices-udid)将回答关于拒绝或接受的问题,使用序列号我想是更好的主意 – nsgulliver 2013-03-07 21:24:47

+3

@Seb你不应该*使用UUID,它最终会被删除。开始一个新的应用程序,我会建议不要像这里的第二个例子那样使用UUID,除非有一个**非常好的理由。 – 2013-03-07 21:25:16