iOS5上的应用程序的UUID [英] UUID for app on iOS5

查看:142
本文介绍了iOS5上的应用程序的UUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

UIDevice uniqueIdentifier已弃用 - 现在该怎么办?

我希望您知道,iOS5中不推荐使用 UIDevice 中的 uniqueIdentifier 。我正在为iOS5寻找基本相同的功能。

As I expect you are aware of, the uniqueIdentifier in UIDevice is deprecated in iOS5. What I am looking for a basically the same functionality for iOS5.

我从文档中了解到,苹果希望我们(开发人员)创建我们自己的UUID(使用 CFUUIDCreate 我猜)并将其存储在 NSUserDefaults 中。然而,这让我颤抖了一点,并没有感到拯救。在这种情况下拥有UUID感觉有点无意义。

What I understand from the documentation is that apple wishes that we (developers) create our own UUID (using CFUUIDCreate I guess) and store it in the NSUserDefaults. This, however, makes me shiver a bit and does not at all feel save. Feels a bit pointless to have a UUID in this case.

我需要UUID的原因是因为我在auth进程中向服务器发送了包含UUID的一堆信息如果服务器可以猜测用户下次启动或重新安装应用程序的用户或其他应用程序实现我的库,则希望能够跳过某些步骤。 CFUUIDCreate 似乎没有帮助我。

The reason I need an UUID is because I send of a bunch information including UUID to my servers in the auth process and would like to be able to skip some steps if the server can "guess" whom the user is next time the app gets launched or re-installed or another app implements my library. CFUUIDCreate does not seem to help me with this.

我快速浏览了 gekitz ,但据我了解,它仅以MAC地址为基础手机中的以太网卡。这是不合适的,因为我有一种模糊的感觉,即MAC地址是可变的。 UIDevice 中的 uniqueIdentifier

I took a quick look at gekitz as well, but as I understand it, it bases it solely on the MAC address of the Ethernet "card" in the phone. This is not suitable since I have a vague feeling that the MAC address is changeable. The uniqueIdentifier in UIDevice was


基于各种硬件详细信息的每个设备唯一的字母数字字符串。

An alphanumeric string unique to each device based on various hardware details.

Currenly我编写了这段代码,用于检索UUID。但是只要我在XCode中清理并在手机上重新安装应用程序,我就会获得一个新的UUID。

Currenly I wrote this code, which retrieves a UUID. But as soon as I clean in XCode and re-install the app on the phone, I get a new UUID.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *UUID = @"";

if (![defaults valueForKey:@"UUID"])
{
    CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
    CFStringRef UUIDSRef = CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
    UUID = [NSString stringWithFormat:@"%@", UUIDSRef];

    [defaults setObject:UUID forKey:@"UUID"];
}
else {
    UUID = [defaults valueForKey:@"UUID"];
}

[deviceInformation setObject:UUID forKey:@"UUID"];

总结一下,我的问题如下:

有吗创建一个基于难以篡改的设备的UUID的一些可靠方法,并让我作为接收器有点依赖和信任的东西?这不必基于设备,可以基于应用程序作为App UUID,只要它在重新安装后相同。

To sum it up, my question is the following:
Is there some solid way of creating an UUID that is based upon the device which is "hard" to tamper with and gives me as receiver a little something to depend and trust upon? This does not have to be based on the device, may be based on the app as a App UUID as long as its the same after a re-installation.

推荐答案

到目前为止,MAC似乎是识别设备唯一已知的稳定方式。

So far, the MAC seems to be the only known "stable" way to identify a device.

看看 Erica Sadun的 UIDevice(硬件)类别,你会请注意,识别唯一有用的是MAC。

Have a look at Erica Sadun's UIDevice(Hardware) category, you'll notice that the only useful thing for identification is the MAC.

她还有一个 UIDevice(IOKit_Extensions)类别确实提供IMEI和序列号。但是,IOKit是私有API。 Erica写道

She also has a UIDevice(IOKit_Extensions) category which does provide IMEI and serial number. However, IOKit is private API. Erica wrote:


正如iPhone传播者Matt Drance所发推的那样,IOKit在iPhone上不公开。缺少标题和文档很少是疏忽。

As iPhone evangelist Matt Drance tweeted, "IOKit is not public on iPhone. Lack of headers and docs is rarely an oversight."

所以使用 IOKit 可能会让你被拒绝。

So using IOKit might get you rejected.

据我所知,用户无法在没有越狱设备的情况下更改MAC(然后他可以做任何他想做的事情)。所以我的建议是忽略jailbreakers并简单地使用基于MAC的UUID。

As far as I know there is no way for a user to change the MAC without jailbreaking the device (and then he can do anything he wants anyway). So my suggestion is to ignore the jailbreakers and simply use a UUID based on the MAC.

警告! MAC地址API在iOS 7中不起作用。

这篇关于iOS5上的应用程序的UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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