【问题标题】:How to prevent keychain data to be included in backup and restore process of the devices when using KeychainSwift?使用 KeychainSwift 时如何防止钥匙串数据包含在设备的备份和恢复过程中?
【发布时间】:2021-04-12 12:07:38
【问题描述】:

我使用KeychainSwift 将我的数据保存在钥匙串上,我的问题是,当我备份和恢复我的应用程序时,从Device ADevice B,钥匙串中的这些数据包含在传输中。

问题是,我怎样才能防止它发生并让我的钥匙串只留在Device A

这是我将数据保存到钥匙串中的代码

import KeychainSwift

class ExampleViewController: UIViewController {
    let keychain = KeychainSwift(keyPrefix: "some_key")

    override func viewDidLoad() {
        keychain.set("some_data", forKey: "thisDeviceOnly")
    }
}

【问题讨论】:

    标签: ios swift backup restore keychain


    【解决方案1】:

    你必须使用 withAccess 参数来设置方法

    您可以在官方KeychainSwift github 上查看可能的值 https://github.com/evgenyneu/keychain-swift/blob/master/Sources/KeychainSwiftAccessOptions.swift

    您需要一些以 ThisDeviceOnly 结尾的访问值,它不会在设备上同步。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-12
      • 1970-01-01
      • 1970-01-01
      • 2017-08-04
      • 2014-04-29
      • 2013-04-26
      相关资源
      最近更新 更多