【问题标题】:Can device token of Push Notification be used as a unique identifier?推送通知的设备令牌可以用作唯一标识符吗?
【发布时间】:2013-08-21 10:16:46
【问题描述】:

问题:不推荐使用 UDID - 我们不能再使用它了。 网上有一些解决方案:生成GUID并存放在“安全的地方”,iCloud,iOS6开头的IdentifierForVendor,OpenUID,SecuredID等等……

请求: 我需要设备的唯一标识符才能在我们的服务器上存储用户数据。

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

这个想法的优缺点是什么?

  • (-) 用户可以禁用推送通知
  • (+) 唯一编号
  • (+) 在所有 iOS 中都支持

【问题讨论】:

    标签: ios


    【解决方案1】:

    这是个糟糕的主意,如果用户更换设备或其他未知原因,令牌可能会更改。

    • 用户可以拥有多个设备
    • 如果用户重新安装应用程序,他们可以获得其他令牌
    • 用户不会 100% 保留相同的令牌。

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

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

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

    【讨论】:

    • 看来唯一的办法就是拥有自己的登录机制
    • 如果用户卸载应用,保存在钥匙串中的 UUID 不会被删除
    • @user1760527 true,但是如果用户清除设备,它可以被清除。
    【解决方案2】:

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

    【讨论】:

    • identifierForVendor 也可以更改。 Apple 文档指出,从一个供应商处卸载所有应用程序然后重新安装会改变它。
    • Apple 的目的是让开发人员无法在不同的、不相关的应用程序之间唯一地识别设备。因此,您的服务器应该将应用程序的卸载和后续安装视为用户的新设备,并带有新的标识符。
    【解决方案3】:
             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/
    

    有人可以建议即使在重新安装应用、删除应用或系统重启或系统启动或恢复出厂设置后仍保留唯一 ID 的最佳方法

    【讨论】:

    • 1.如果用户重置设备,identifierForVendor 也会发生变化。 2. Apple 很可能会拒绝此代码 3. 如果用户更新到 iOS6,您正在为同一用户使用不同的标识符。 IE。他的所有数据都将消失。
    • @MatthiasBauch:那么解决方案呢?
    • Apple 拒绝此代码。他们执行静态分析,任何对 uniqueIdentifier 的调用都将被标记并拒绝应用程序。这是在上传时完成的。
    • 我不知道上面的代码会在 Apple 中被拒绝,但是当 ios 5 发布时我已经使用以下代码作为唯一设备 ID github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5
    • 朋友,建议的解决方案是什么?
    猜你喜欢
    • 2010-11-23
    • 1970-01-01
    • 1970-01-01
    • 2018-02-13
    • 2011-12-30
    • 1970-01-01
    • 2012-02-26
    • 1970-01-01
    相关资源
    最近更新 更多