简体   繁体   English

卸载iOS应用时删除钥匙串

[英]Deleting Keychain when uninstalling iOS app

I have been reading several posts regarding this issue, for example Delete keychain items when an app is uninstalled and iOS autodelete Keychain items after uninstall? 我已经阅读了有关此问题的几篇文章,例如, 在卸载应用程序时删除钥匙串项以及在卸载后iOS自动 删除钥匙串项 . They say that, when you uninstall an app, its Keychain is not deleted, but the posts may be deprecated, is that the current behaviour? 他们说,当您卸载应用程序时,不会删除其“ Keychain ,但帖子可能已被弃用,这是当前行为吗?

On the other hand, if Keychain is not really automatically deleted when the user uninstalls an app, I'm not clear about the way to do that yourself. 另一方面,如果用户卸载应用程序时Keychain并没有真正自动删除,则我不清楚自己的方式。

EDIT: If Keychain are not deleted when apps are uninstalled, what actually happens to all those residual Keychain ? 编辑:如果在卸载应用程序时未删除Keychain ,那么所有这些剩余的Keychain实际上会发生什么? Does the system not handle that? 系统不处理吗?

There is no trigger to perform code when the app is deleted from the device. 从设备删除应用程序后,没有触发器可以执行代码。 Access to the keychain is dependent on the provisioning profile that is used to sign the application. 对钥匙串的访问取决于用于对应用程序进行签名的供应配置文件。 Therefore no other applications would be able to access this information in the keychain. 因此,没有其他应用程序能够访问钥匙串中的此信息。

I don't think you need to delete it. 我认为您不需要删除它。 I'm not sure how to delete it but I believe if you did set the keychain value to some certain then you can also assign the value of nil or just empty string "" . 我不确定如何删除它,但是我相信如果您确实将钥匙串的值设置为某个值,那么您还可以分配nil的值或只是空字符串"" But this is not quite sure, just assuming. 但这并不确定,只是假设而已。

Hope it helps! 希望能帮助到你!

Try using UserDefaults to store a boolean that tracks when data is saved to the keychain. 尝试使用UserDefaults存储一个布尔值,该布尔值跟踪何时将数据保存到钥匙串。

Example: 例:

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

Then in AppDelegate in the didFinishLaunchingWithOptionsMethod 然后在AppDelegate中的didFinishLaunchingWithOptionsMethod

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

Since UserDefaults is cleared on application uninstall, the next time the user installs the application, that key-value will be gone therefore on start up, your AppDelegate will delete the residual Keychain data. 由于UserDefaults在应用程序卸载时被清除,因此下次用户安装该应用程序时,该键值将消失,因此在启动时,您的AppDelegate将删除残留的Keychain数据。

I've searched far and wide as well, this workaround is the closest you can get. 我也进行了广泛的搜索,这种解决方法是您可以获得的最接近的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS用户如何在卸载应用程序后删除钥匙串 - How can a iOS user remove keychain after uninstalling app 已删除 iOS 证书在重新启动 Xcode 后仍显示在钥匙串中,即使从钥匙串访问和 App Store Connect 中删除它也是如此 - Deleted iOS Certificate keeps showing up in keychain when restarting Xcode even after deleting it from keychain access and App Store Connect 它是卸载iOS应用程序时删除的领域文件 - Is it the realm file deleted when uninstalling iOS app Facebook iOS-在SSO上禁止应用程序然后卸载应用程序时出错 - Facebook iOS - Error when disallowing app on SSO and then uninstalling app 将应用程序还原到新设备时,iOS钥匙串存储是否仍然存在? - Does iOS keychain storage persist when restoring an app to a new device? Mac OSX在构建MonoDevelop iOS App时要求进行密钥链访问 - Mac OSX asking for keychain access when building MonoDevelop iOS App 删除iOS应用时删除私人(钥匙串)数据 - Remove private (keychain) data when iOS app is removed 使用钥匙串提高iOS应用安全性 - Increase iOS App Security With Keychain 应用被杀死时删除钥匙串 - Delete Keychain when app is killed 在 iOS 中卸载应用程序时如何从钥匙串中删除存储的用户名和密码? - How to remove the stored username and password from keychain while uninstalling application in iOS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM