手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆

IOS不再允许使用UDID

首页 > 苹果相关 >

上面一则新闻来自macx,原文地址是:http://www.macx.cn/thread-2041511-1-1.html
iOS设备的设备唯一识别码UDID(unique device identifier),顾名思义就是每个设备只有这一个标识符,与设备硬件相关,是无法更改的。根据报道苹果从本周开始已经开始禁止第三方应用程序使用 iOS设备的UDID,并指出苹果将在下周开始加强设备UDID的隐私保护。

在iOS 5条款中,苹果已经对开发者进行了提醒,使用用户设备UDID是不赞成的并将逐步取缔这一做法。消息称苹果的十个App审核团队中已经有两个开始禁止使用UDID的应用通过审核了,据说下周将增加到四个。

一些第三方开发者表示,如果苹果有明确禁止使用UDID的条款颁布,那他们会按照新标准执行,不过他们还希望看看未来的形式如何发展。无论是开发者还是广告商都将受到新政策的严重影响。

苹果最近被隐私问题腿上风口浪尖,美国国会也几次三番要求苹果解释隐私保护问题,苹果可能也是出于外接压力才进一步紧缩iOS条款的。

如何查看自己iOS设备的UDID:
将设备链接到电脑iTunes,本机信息原来显示序列号的地方点击一下,即可看到标示符UDID信息
----------------
基于上述新闻,于是就有了下面这篇文章,嗯,当然也不是我写的,原文地址是:http://pingguohe.net/2011/08/25/uuid_after_ios5/

iOS5已经发布了6个beta版,除了在用户体验上的提升,对于开发者来说也有很多变化,最大的莫过于对UDID的限制访问。在之前的iOS应用 中,我们一般使用UDID来标记一个用户,基于UUID建立用户数据库。现在,安装了iOS5 beta 6的设备上已经取不到UDID,[UIDevice uniqueIdentifier] 只能返回一个“5.0”了。

取代被禁用的iOS UDID,其实有很多方法,比如,有人建议使用网卡mac,但我不建议使用这种方法,mac地址属于用户隐私数据,我想如果你试图获取用户mac并上传,review通不过。

官方给出的建议是CFUUID:

An alphanumeric string unique to each device based on various hardware details. (read-only) (Deprecated in iOS 5.0. Instead, create a unique identifier specific to your app.)

@property (nonatomic, readonly, retain) NSString *uniqueIdentifier
Special Considerations

Do not use the uniqueIdentifier property. To create a unique identifier specific to your app, you can call the CFUUIDCreate function to create a UUID, and write it to the defaults database using the NSUserDefaults class.

通过CFUUIDCreate创建一个CFUUID对象,存入NSUserDefaults,作为用户身份的唯一标示。

官方对CFUUID对象的解释如下:

CFUUID objects are used by plug-ins to uniquely identify types, interfaces, and factories. When creating a new type, host developers must generate UUIDs to identify the type as well as its interfaces and factories.

UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs (Interface Identifiers), are 128-bit values guaranteed to be unique. A UUID is made unique over both space and time by combining a value unique to the computer on which it was generated—usually the Ethernet hardware address—and a value representing the number of 100-nanosecond intervals since October 15, 1582 at 00:00:00.

The standard format for UUIDs represented in ASCII is a string punctuated by hyphens, for example 68753A44-4D6F-1226-9C60-0050E4C00067. The hex representation looks, as you might expect, like a list of numerical values preceded by 0x. For example, 0xD7, 0x36, 0x95, 0x0A, 0x4D, 0x6E, 0x12, 0x26, 0x80, 0x3A, 0x00, 0x50, 0xE4, 0xC0, 0x00, 0x67 . To use a UUID, you simply create it and then copy the resulting strings into your header and C language source files. Because a UUID is expressed simply as an array of bytes, there are no endianness considerations for different platforms.

可以看到CFUUID就是对GUID的一种封装,提供了创建方法和各种各种格式转换的方法。

以下代码是我对CFUUID和NSUserDefaults的封装,可以作为唯一标识来使用。

C++代码
  1. //  
  2. //  NewUUID.h  
  3. //  
  4. //  Created by jiajun.gao jiajun.gao on 8/25/11.  
  5. //   
  6. //  Create a UUID by self.  
  7. //  
  8. //  Call like this:  
  9. //  
  10. //    String *iNeedUUID = [NewUUID identifier];  
  11. //  
  12.    
  13. #define NEW_UUID_KEY    @"uuid_created_by_developer"  
  14.    
  15. @interface NewUUID : NSObject {  
  16.    
  17.     NSString *uuid;  
  18.    
  19. }  
  20.    
  21. + (NSString *)identifier;  
  22.    
  23. @property (nonatomic, retain) NSString *uuid;  
  24.    
  25. @end  

NewUUID.m

C++代码
  1. #import <Foundation/Foundation.h>  
  2.    
  3. #import "NewUUID.h"  
  4.    
  5. @implementation NewUUID  
  6.    
  7. @synthesize uuid;  
  8.    
  9. - (id)init {  
  10.     self = [super init];  
  11.     if (self) {  
  12.         uuid = NULL;  
  13.         return self;  
  14.     }  
  15.    
  16.     return nil;  
  17. }  
  18.    
  19. + (id)_instance {  
  20.     static id obj = nil;  
  21.     if( nil == obj ) {  
  22.         obj = [[self alloc] init];  
  23.     }  
  24.    
  25.     return obj;  
  26. }  
  27.    
  28. + (NSString *)identifier {  
  29.    
  30.     NSUserDefaults *handler = [NSUserDefaults standardUserDefaults];  
  31.     [[NewUUID _instance] setUuid:[NSString stringWithFormat:@"%@", [handler objectForKey:NEW_UUID_KEY]]];  
  32.    
  33.     if (NULL == [[NewUUID _instance] uuid] || 46 > [[[NewUUID _instance] uuid] length]) {  
  34.    
  35.         CFUUIDRef uuid = CFUUIDCreate(NULL);  
  36.         CFStringRef uuidStr = CFUUIDCreateString(NULL, uuid);  
  37.    
  38.         NSString *result = [NSString stringWithFormat:@"%@-%@", @"new-uuid-", uuidStr];  
  39.    
  40.         CFRelease(uuidStr);  
  41.         CFRelease(uuid);  
  42.    
  43.         [[NewUUID _instance] setUuid:result];  
  44.    
  45.    
  46.         [handler setObject:[[NewUUID _instance] uuid] forKey:NEW_UUID_KEY];  
  47.         [handler synchronize];  
  48.     }  
  49.    
  50.     return [[NewUUID _instance] uuid];  
  51. }  
  52.    
  53. @end  

 

 

 




本站采用创作共享版权协议, 要求署名、非商业和保持一致. 本站欢迎任何非商业应用的转载, 但须注明出自"易栈网-膘叔", 保留原始链接, 此外还必须标注原文标题和链接.

Tags: ios, udid

« 上一篇 | 下一篇 »

只显示10条记录相关文章

资料备份:ios(苹果)设备直播流媒体 服务搭建 (浏览: 36419, 评论: 0)
IOS设置横竖屏 (浏览: 25254, 评论: 0)
笔记:IOS发送图片的时候,还是用的$_FILES (浏览: 19544, 评论: 1)
关于APNS的一些事(是以前的补充) (浏览: 18607, 评论: 1)
ipad ,ios 4.2 (浏览: 18078, 评论: 0)
知识点: RAD Studio XE2新特性概览:多平台支持、原生iOS与Android、HD与3D动画及云 (浏览: 17582, 评论: 0)
转:ios拷贝小议 (浏览: 16465, 评论: 0)
转:30秒钟做一个ipa (浏览: 16227, 评论: 0)
IOS6,我是升呢还是不升呢 (浏览: 16015, 评论: 1)
ios7试用一周多小记 (浏览: 15285, 评论: 0)

2条记录访客评论

我想是错的,mac地址是能通过review的,我刚通过的。

Post by hhuai on 2012, August 21, 2:15 PM 引用此文发表评论 #1

无解啊。UDID的作用是仅区别设备,而这个解决方案,只能对每一次“APP安装”做了区分。
-----
只能将就一点了。否则怎么办。

Post by OpLusX on 2012, March 29, 5:57 PM 引用此文发表评论 #2


发表评论

评论内容 (必填):