Closed rjong closed 7 years ago
@rjong Values that you stored into the keychain will remain there unless you remove them by code or reset and remove all the data in the phone. If you want them to be deleted when deleting the app, you probably want to store them somewhere else.
Allright, thanks for the answer.
@rjong As a workaround, you could have a flag in Userdefaults
which will track if the app launch is from fresh install or not. If it's a fresh install, you can manually delete the keychain items.
Something like this:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if !UserDefaults.standard.bool(forKey: "firstTimeLaunchOccurred") {
KeychainWrapper.standard.removeAllKeys()
UserDefaults.standard.set(true, forKey: "firstTimeLaunchOccurred")
}
return true
}
Something like this:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { if !UserDefaults.standard.bool(forKey: "firstTimeLaunchOccurred") { KeychainWrapper.standard.removeAllKeys() UserDefaults.standard.set(true, forKey: "firstTimeLaunchOccurred") } return true }
Tried but removeAllKeys() returns false and Keychain is not cleared Any suggestions?
Hi there,
When my app sets some values in the Keychain with your library, it is still there even after deleting the app. You can test this by install the app, save some values, delete the app and install it again.
Is there a way to delete the values when the app is deleted?
Thanks.