2013-08-21 144 views
3

问题:使用UDID已被弃用 - 我们不能再使用它了。 有在网络上的一些解决方案:生成GUID并将其存储在“安全的地方”,iCloud中,IdentifierForVendor开始iOS6的,OpenUID,SecuredID等等...推送通知的设备令牌可以用作唯一标识符吗?

请求: 我需要有一个独特的在我们的服务器上存储用户数据的设备的标识符。

问题: 我可以使用Push Notification的deviceToken作为唯一标识符吗?

这个想法有什么优点和缺点?

  • ( - ),用户可以关闭推送通知
  • (+),唯一编号
  • (+),支持所有iOS

回答

0

您应该使用identifierForVendor。用于推送通知的deviceToken是唯一的,但CAN可以更改。

+2

identifierForVendor可以改变的最好办法了。 Apple文档声明,从一个供应商卸载所有应用程序然后重新安装将会改变它。 –

+1

Apple的意图是让开发人员无法在不同的,不相关的应用程序之间唯一标识设备。因此,应用程序的卸载和随后的安装应该被服务器视为用户的新设备,并带有新的标识符。 – Marcel

2

这是一个可怕的想法,如果用户更改设备或其他未知原因,令牌可能会改变。

  • 如果用户重新安装应用程序,他们可以得到其他令牌
  • 这不是100%的用户将使用同一令牌的用户可以拥有多个设备

而且最重要的是:You are identifying devices not users!

一种解决方案是生成一个UUID,并将其保存在您检索用户的钥匙串。但是,如果用户清除设备,也可以将其删除。

您最好的选择是允许用户使用可创建的帐户登录。然后你可以将它与钥匙串中的UUID结合起来。

+0

看来,唯一的解决方案是有我自己的登录机制 – Arkady

0
  The token can change if the user reset the device, for unique device identifying you can use the following code 

      float currentVersion = 6.0; 
      NSString *udid = nil; 
      if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion) 
      { 
     //below code is taken from the Apple Sample code, to check you can download the files 
     https://developer.apple.com/library/ios/releasenotes/StoreKit/IAP_ReceiptValidation 
     // OR 
     http://developer.apple.com/library/ios/releasenotes/StoreKit/IAP_ReceiptValidation/VerificationController.zip (line number 319) 

     udid = [UIDevice currentDevice].identifierForVendor.UUIDString; 

      } 
      else 
      { 
     //may cause apple rejection   
     udid = [UIDevice currentDevice].uniqueIdentifier; 

     //i think we can use the below link for ios5 or below but not sure it may accept or reject 
     https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5 
      } 

//just saw a link which may help you better and have a look at image 
http://www.doubleencore.com/2013/04/unique-identifiers/ 

enter image description here

可以有人建议坚持的唯一ID,即使重新安装应用程序后,删除应用程序或系统重启或系统启动或恢复到出厂默认

+0

这对我来说很好。苹果是否会批准此代码? – Arkady

+3

1.如果用户重置设备,'identifierForVendor'也会改变。 2. Apple很可能会拒绝此代码3.如果用户更新到iOS6,则您将为同一用户使用不同的标识符。即他的所有数据都将消失。 –

+0

@MatthiasBauch:那么Wats解决方案? – Pradeep