【问题标题】:Phonegap/cordova- Ios Device UUID not unique when user uninstall and re-install the appPhonegap/cordova-当用户卸载并重新安装应用程序时,Ios 设备 UUID 不是唯一的
【发布时间】:2017-12-09 23:44:39
【问题描述】:

问题在于 ios 设备,当用户卸载并重新安装应用程序时,它会生成新的 UUID,它不是唯一的。

在 android 设备上,我们可以获得唯一的设备 UUID。

【问题讨论】:

    标签: ios cordova phonegap-build uuid keychain


    【解决方案1】:

    这就是我的诀窍。它对我有用。

    使用钥匙串插件

    Keychain 插件允许您在 iOS 中安全地存储数据 钥匙扣。

    您可以使用此插件设置、获取和删除钥匙串中的值。 钥匙串中存储的项目在卸载和重新安装您的 应用程序。该数据不可用于任何其他应用程序,除非已签名 具有相同的配置文件。当用户备份 iOS 数据时, 备份钥匙串数据,但钥匙串中的秘密仍然存在 在备份中加密。

    钥匙串将数据存储为键值对。您需要设置并获取 这些对使用相同的服务名称。如果您设置现有密钥 使用新值,旧值将被覆盖

    Phonegap Build 用户只需将此插件用于 config.xml 文件

     <plugin name="cordova-keychain" source="npm" />
    

    如何在 App 中使用?

    // prepare some variables
    var servicename = 'MyAppUUID';
    var key = 'MyApp';
    var value = 'Your UUID'; // Set your Device Id here.
    
    // prepare the callback functions
    function onSuccess (msg) {alert(msg)};
    function onError (msg) {alert(msg)};
    
    // store your password in the Keychain
    new Keychain().setForKey(onSuccess, onError, key, servicename, value);
    
    // get your password from the Keychain
    new Keychain().getForKey(onSuccess, onError, key, servicename);
    
    // remove your password from the Keychain
    new Keychain().removeForKey(onSuccess, onError, key, servicename);
    

    【讨论】:

    • 请注意,在 iOS 10.3 测试阶段,跨应用程序安装的钥匙串项目的持久性被短暂禁用,尽管它已恢复,但 Apple 表示此功能从未记录在案并且可以关闭。我怀疑在 iOS 11 中包含 DeviceCheck 框架可能是在未来版本中重新引入钥匙串清除的一步。
    猜你喜欢
    • 1970-01-01
    • 2016-04-25
    • 1970-01-01
    • 2014-12-29
    • 1970-01-01
    • 2014-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多