iOS唯一用户标识符 [英] iOS unique user identifier

查看:105
本文介绍了iOS唯一用户标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写iphone应用程序,它使用REST与我的服务器通信。主要问题是,我需要以某种方式识别用户。不久前,我们被允许使用UDID,但现在不再允许了。那我应该用什么呢?我需要在iphone上使用某种标识符,因此用户将删除应用程序,再次安装它,并且他将获得相同的ID。

I'm writting an application for iphone, which communicates with my server using REST. The main problem is, I need to identify user somehow. Not so long ago, we were allowed to use UDID, but now its not allowed anymore. So what should I use instead? I need some kind of identifier on iphone, so user will delete application, install it again, and he will get same id.

推荐答案

首先,UDID是仅弃用在iOS 5中。这并不意味着它已经消失了。

Firstly, the UDID is only deprecated in iOS 5. That doesn't mean it's gone (yet).

其次,你应该问自己是否真的需要这样的东西。如果用户获得新设备并在其上安装您的应用程序该怎么办?相同的用户,但UDID已更改。同时,原始用户可能已经售出了他的旧设备,所以现在一个全新的用户安装你的应用程序,你认为它是基于UDID的不同的人。

Secondly, you should ask yourself if you really need such a thing. What if the user gets a new device and installs your app on that? Same user, but the UDID has changed. Meanwhile, the original user might have sold his old device so now a completely new user installs your app and you think it's a different person based on the UDID.

如果你不喜欢不需要UDID,使用 CFUUIDCreate()来创建一个唯一的ID,并在首次启动时将其安全保存到用户默认值(使用 CFUUIDCreateString()首先将UUID转换为字符串)。它将在备份和恢复后继续存在,甚至在原始用户切换到新设备时也会出现。它在很多方面都是UDID的更好选择。

If you don't need the UDID, use CFUUIDCreate() to create a unique ID and safe it to the user defaults on first launch (use CFUUIDCreateString() to convert the UUID to a string first). It will survive backups and restores and even come along with the original user when they switch to a new device. It's in many ways a better option that the UDID.

如果你真的需要一个独特的设备标识符(听起来不像你做的那样) ),按照Suhail的回答中指出的MAC地址。

If you really need a unique device identifier (it doesn't sound like you do), go for the MAC address as pointed out in Suhail's answer.

这篇关于iOS唯一用户标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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