iOS5 上应用程序的 UUID
正如我所期望的那样请注意,UIDevice
中的 uniqueIdentifier
在 iOS5 中已被弃用。我正在寻找与iOS5基本相同的功能。
我从文档中了解到,苹果希望我们(开发人员)创建自己的 UUID(我猜是使用 CFUUIDCreate )并将其存储在 NSUserDefaults 中。然而,这让我有点颤抖,一点也没有被拯救的感觉。在这种情况下,拥有 UUID 感觉有点毫无意义。
我需要 UUID 的原因是因为我在身份验证过程中将包括 UUID 在内的一堆信息发送到我的服务器,并且如果服务器可以在下次启动应用程序时“猜测”用户是谁,我希望能够跳过一些步骤或重新安装或另一个应用程序实现我的库。 CFUUIDCreate
似乎对我没有帮助。
我也快速浏览了 gekitz ,但是据我了解,它仅基于手机中以太网“卡”的 MAC 地址。这是不合适的,因为我隐约感觉MAC地址是可变的。 UIDevice
中的 uniqueIdentifier
是
基于各种硬件详细信息,每个设备唯一的字母数字字符串。
目前我编写了这段代码,它检索 UUID。但一旦我清理 XCode 并在手机上重新安装应用程序,我就会得到一个新的 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,并为我作为接收者提供一些值得依赖和信任的东西?这不必基于设备,可以基于应用程序作为应用程序 UUID,只要重新安装后相同即可。
Possible Duplicate:
UIDevice uniqueIdentifier Deprecated - What To Do Now?
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.
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.
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.
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 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"];
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
到目前为止,MAC 似乎是唯一已知的“稳定”的设备识别方式。
看看 Erica Sadun 的
UIDevice(硬件)
类别,您就知道了您会注意到,唯一对识别有用的是 MAC。她还有一个
UIDevice(IOKit_Extensions)
类别,该类别提供 IMEI 和序列号。然而,IOKit 是私有 API。 艾丽卡写道:因此,使用 IOKit 可能会让您被拒绝。
据我所知,用户无法在不越狱设备的情况下更改 MAC(然后他就可以做任何他想做的事情)。所以我的建议是忽略越狱者并简单地使用基于MAC的UUID。
警告! MAC 地址 API 在 iOS 7 中不起作用。
So far, the MAC seems to be the only known "stable" way to identify a device.
Have a look at Erica Sadun's
UIDevice(Hardware)
category, you'll notice that the only useful thing for identification is the MAC.She also has a
UIDevice(IOKit_Extensions)
category which does provide IMEI and serial number. However, IOKit is private API. Erica wrote:So using
IOKit
might get you rejected.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.
Warning! MAC address APIs will not work in iOS 7.