About UDID

原创 2012年03月22日 00:18:52

How to Replace the UDID

iOS 5 is still in beta, yet Techcrunch revealed a few weeks ago that Apple will deprecate the -[UIDevice uniqueIdentifier] method in iOS 5. This method returns a device’s UDID, the 40 character hex string that uniquely identifies each device.

Many developers use this value to anonymously track usage of their apps or to create user accounts on an app-related web service without requiring the user to register an account manually. Unfortunately, the nature of the UDID also makes it easy to track users across multiple apps if those apps talk to the same webservice such as an ad network or analytics service, as so many apps do.

Apple apparently considers this a big enough privacy problem to phase out developer access to the UDID (and rightly so if you ask me). So what should you do if your app relies on the UDID at the moment?

Don’t Panic

Keep in mind that the method has just been deprecated in iOS 5, not removed. So for the time being, nothing really changes. Apple probably won’t remove it until the release of iOS 6 or even later, so you have plenty of time to consider alternatives.

The MAC Address as a Replacement

Every network adapter on the planet needs a unique MAC address to identify itself on the network. Since every iOS device has at least one network interface, the MAC address can serve as a full replacement for the UDID. Check out this code on GitHub by Georg Kitz to find out how to access it on an iOS device.

You don’t need to access private APIs to retrieve the MAC address so this should be safe for the App Store. Still, Apple clearly intends to block access to identifiers that can be used to track user behavior across multiple apps. Depending on what you use this identifier for, I would expect Apple to reject apps that do “malicious” user tracking based on the MAC address in the future.

Rather than blindly replacing the UDID with the MAC address, I urge you to think about your actual requirements. Do you really need a unique hardware identifier? I would argue that in most cases, a uniqueuser identifier is much more useful.

Do You Really Need a Hardware Identifier

Both the UDID and the MAC address are device identifiers. As such, they don’t tell you anything about a specific user. While the iPhone and iPod touch are primarily personal devices and thus normally only used by one person, this is less true for the iPad, which gets often shared by a family. Also, most people will replace their device with a new one sooner or later, and often they will sell their old device or give it away to a family member.

This is a real problem if your webservice equates the hardware identifier with a specific user when it really should have been tracking users instead of devices all along. So we would have to replace the UDID with a user ID. Such a user identifier should survive software updates, full system restores and device replacements, which is more than the UDID or MAC address can do. Ideally, it should also identify the same user on multiple devices (such as an iPhone and an iPad). Admittedly, that is not possible with the simple solution I present here.

Self-made UUIDs

To create our own unique identifier, we use the Core Foundation function CFUUIDCreate(). It returns a reference to an opaque type CFUUIDRef, which we can convert into a string with theCFUUIDCreateString function.

It is good practice to wrap these calls in a small NSString category so that we can reuse them easily (UUIDs come in handy in many cases, for example if you need to generate unique filenames):

@interface NSString (UUID)

+ (NSString *)uuid;

@end


@implementation NSString (UUID)

+ (NSString *)uuid
{
    NSString *uuidString = nil;
    CFUUIDRef uuid = CFUUIDCreate(NULL);
    if (uuid) {
        uuidString = (NSString *)CFUUIDCreateString(NULL, uuid);
        CFRelease(uuid);
    }
    return [uuidString autorelease];
}

@end

Now, in our code, we generate a fresh UUID on the first launch of our app and store it to the user defaults database:

#define UUID_USER_DEFAULTS_KEY @"UUID"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:UUID_USER_DEFAULTS_KEY] == nil) {
        [defaults setObject:[NSString uuid] forKey:UUID_USER_DEFAULTS_KEY];
        [defaults synchronize];
    }
    
    ...

That way, our UUID will automatically be backed up and restored to a new device.

序列号和设备标识UDID码手机直接获取方式

1 设备标识UDID码获取:http://fir.im/udid 或者直接手机自带的浏览器输入那个网站链接也可以的。 打开链接点击右上角3点点击在Safari浏览器中打开,就是像一个指南中的图标点进...
  • sinat_30585999
  • sinat_30585999
  • 2016年03月28日 00:18
  • 3191

开发者证书添加UDID流程

1.进入开发者账号里面,点击All Devices, 2.点击右上角的+,添加UDID。 3.填写UDID和这个UDID气的名字,然后点击continue,再点击同意就添加上了 ...
  • chenyongkai1
  • chenyongkai1
  • 2016年08月30日 15:22
  • 4820

如何快速在手机中查看UDID,无需itunes、itools

第一步:使用iPhone/iPad打开这个网页 http://udid.iosbeta.cn/udid   如果嫌麻烦也可以电脑打 http://udid.iosbeta.cn/udid,之后会出现...
  • st646889325
  • st646889325
  • 2016年10月29日 13:47
  • 1814

查看手机UDID的方法

1.    将手机用数据线连接到装有itunes(如下图)的电脑上 2.    出现下图a界面后,点击左上角的手机图标(图b),后进入到图c界面 图a 图b ...
  • iOS_yanmy
  • iOS_yanmy
  • 2016年12月16日 15:28
  • 1117

关于不通过手机UDID安装测试app

一、首先在AppStore 下载TestFight这个软件; 二、在手机的邮件app里登录自己的邮箱; 三、邮箱登录好了以后把邮箱发给IT开发人员,开发人员通过TestFight外部测试把测试包发到你...
  • Peng_Ruan
  • Peng_Ruan
  • 2017年02月04日 10:21
  • 686

iPhone 查看UDID 方法

UDID是什么?UDID是由子母和数字组成的40个字符串的序号,用来区别每一个唯一的iOS设备,包括iPhone/iPads以及iPod touches都有一个UDID,这些编码看起来是随机的,实际上...
  • ganggelove
  • ganggelove
  • 2016年05月18日 11:20
  • 5263

iOS UDID和UUID的区别

UDID: UDID的全名为Unique Device Identifier(设备唯一标识符)。从名称上也可以看出,UDID这个东西是和设备有关的,而且是只和设备有关的,有点类似于MAC地址。UDID...
  • youshaoduo
  • youshaoduo
  • 2017年06月14日 10:54
  • 5740

更改udid来重置软件到期

1、没有购买正版的FY。 现在IOS5 只能授权一段时间。过了时间就出广告,看着很烦,不去广告就占据了三分之一的位置!  首先在源里面搜索下载UDIDFaker这个。 2、等biteSMS授权...
  • pastway
  • pastway
  • 2012年07月15日 09:30
  • 2242

将新设备的UDID添加到开发者账号,打包.ipa

1.查询设备的UDID 先展示出来的是序列号,点击序列号切换到UDID,右击复制 2.向开发者中心添加UDID 如果只需添加一个,填上设备的Name和UDID点击Continue就好了,如果想...
  • yuanpeng1014
  • yuanpeng1014
  • 2016年09月24日 09:20
  • 519

苹果手机快速获取UDID方式

开发过程中,可能需要许多客户提供苹果手机的UDID方便他们了解项目进度,然而对于客户来说,通过iTunes方法获取过于繁琐,该方法可以快速获取UDID,操作方便,十分快捷!...
  • IXiaLuo
  • IXiaLuo
  • 2016年10月14日 09:20
  • 616
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:About UDID
举报原因:
原因补充:

(最多只允许输入30个字)