iPhone设备ID(UDID)的替代方案

时间:2012-03-09 09:22:28

标签: iphone objective-c ios validation uniqueidentifier

  

可能重复:
  UIDevice uniqueIdentifier Deprecated - What To Do Now?

即使Apple没有参加Barcelone的MWC(移动世界大会),也有可能会在更进一步的iOS SDK中弃用设备ID。

我不明白Apple为什么要限制这个,但那不是主题。

我必须准备好我的应用程序,因为我的用户已被识别并且知道更好地使用我的应用程序(例如,不需要登录或创建帐户)。而且我确信在那种情况下我并不孤单。

所以有人知道获取deviceID的替代方案吗?是否有其他唯一标识符,例如MAC地址?你如何准备你的应用程序?

3 个答案:

答案 0 :(得分:5)

<强>更新

使用CFUUID生成UUID怎么样?您可以在第一次发布时将其存储在 KEYCHAIN 中。 你可以这样得到它......

NSString *uuid = nil;
CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault);
if (theUUID) {
  uuid = NSMakeCollectable(CFUUIDCreateString(kCFAllocatorDefault, theUUID));
  [uuid autorelease];
  CFRelease(theUUID);
}

并且通过弃用uniqueIdentifier方法,Apple建议您不要识别每个设备,而是每个应用程序安装。可能是明天他们可能决定拒绝你的应用程序这样做..:/ 希望这会有所帮助。

答案 1 :(得分:2)

试试这个

- (NSString *)getDeviceID
{
    NSString *uuid = [self gettingString:@"uniqueAppId"];
    if(uuid==nil || [uuid isEqualToString:@""])
    {
        CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault);
        if (theUUID)
        {
            uuid = NSMakeCollectable(CFUUIDCreateString(kCFAllocatorDefault, theUUID));
            [self savingString:@"uniqueAppId" data:uuid];
            [uuid autorelease];
            CFRelease(theUUID);
        }
    }
    return uuid;

// this is depreciated  
//  UIDevice *device = [UIDevice currentDevice];
//  return [device uniqueIdentifier];
}

答案 2 :(得分:2)

请实施新逻辑以获取Secure UDID.it由第三方提供

Learn about free solution:

这确实很好用,并且很容易实现,而不必大肆替换已弃用的方法。