UDID更换? [英] UDID Replacement?

查看:140
本文介绍了UDID更换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 [[UIDevice currentDevice] uniqueIdentifier] 被拒绝,我用过:

I know [[UIDevice currentDevice] uniqueIdentifier] is being rejected, I used :

- (NSString *) uniqueDeviceIdentifier{
    NSString *macaddress = [[UIDevice currentDevice] macaddress];
    NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];

    NSString *stringToHash = [NSString stringWithFormat:@"%@%@",macaddress,bundleIdentifier];
    NSString *uniqueIdentifier = [stringToHash stringFromMD5];

    return uniqueIdentifier;
}

如果我的方法未经Apple批准,我可以采用哪种方法获得独特的标识符?

If my method is not approved by Apple, what method can I get a unique identifier?

推荐答案

这个项目与你正在做的事情类似: https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5 。我相信它现在被Apple接受了。要真正回答您的问题,没有其他(公共)方式获取不仅是唯一的ID,而且每个应用都是相同的。 @ Vishal的使用方法:

This project does something similar to what you're doing: https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5. I believe it is being accepted by Apple for now. To actually answer your question, there is no other (public) way of getting a id that is not only unique but the same for every app. @Vishal's method of using:

+ (NSString *)GetUUID {
  CFUUIDRef theUUID = CFUUIDCreate(NULL);
  CFStringRef string = CFUUIDCreateString(NULL, theUUID);
  CFRelease(theUUID);
  return [(NSString *)string autorelease];
}

和@ JeffWolski的使用方法:

and @JeffWolski's method of using:

[[NSUUID UUID] UUIDString];

如果您不需要设备ID在应用程序之间保持一致,只需要一种方法识别您自己的特定设备。如果您需要在应用程序之间工作的设备ID,则需要使用您的代码或开源项目来使用设备MAC地址。

work if you don't need the device id to be consistant between apps and just need a way to identify that specific device within your own. If you need a device ID that works between apps, you will need to use the devices MAC address either using your code or a open source project.

UPDATE

我刚刚找到另一个解决方案。您可以使用 [[UIDevice currentDevice] identifierForVendor] 。同样,此设备ID对您的应用来说也是唯一的。 http:/ /developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/identifierForVendor

I just found another solution. You can use [[UIDevice currentDevice] identifierForVendor]. Again, this device id will be unique to your app. http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/identifierForVendor

这篇关于UDID更换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆