gpt4 book ai didi

ios - 卸载 iOS 应用程序时删除钥匙串(keychain)

转载 作者:搜寻专家 更新时间:2023-11-01 06:17:33 24 4
gpt4 key购买 nike

我已经阅读了几篇关于这个问题的帖子,例如 Delete keychain items when an app is uninstallediOS autodelete Keychain items after uninstall? .他们说,当您卸载应用程序时,它的 Keychain 不会被删除,但帖子可能会被弃用,这是当前的行为吗?

另一方面,如果 Keychain 在用户卸载应用程序时没有真正自动删除,我不清楚自己的方法。

编辑:如果在卸载应用程序时未删除 Keychain,那么所有那些残留的 Keychain 实际发生了什么?系统不处理吗?

最佳答案

尝试使用 UserDefaults 来存储一个 bool 值,用于跟踪何时将数据保存到钥匙串(keychain)。

例子:

func someFunctionThatSavesToKeychain {
// Save to keychain
UserDefaults.standard.set(true, forKey: "isSavedToKeychain")
// Do other stuff
}

然后在AppDelegate中的didFinishLaunchingWithOptionsMethod

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if !UserDefaults.standard.bool(forKey: "isSavedToKeychain") {
// Delete data from Keychain
}
}

由于 UserDefaults 在应用程序卸载时被清除,下次用户安装应用程序时,该键值将消失,因此在启动时,您的 AppDelegate 将删除残留的钥匙串(keychain)数据。

我也进行了广泛的搜索,此解决方法是您可以获得的最接近的解决方法。

关于ios - 卸载 iOS 应用程序时删除钥匙串(keychain),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41099718/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com