Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Items still in Keychain after removal #98

Closed
rjong opened this issue Jul 25, 2017 · 5 comments
Closed

Items still in Keychain after removal #98

rjong opened this issue Jul 25, 2017 · 5 comments

Comments

@rjong
Copy link

rjong commented Jul 25, 2017

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.

@rjong rjong changed the title Still items in Keychain after removal Items still in Keychain after removal Jul 25, 2017
@Shermanaters
Copy link

@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.

@rjong
Copy link
Author

rjong commented Jul 27, 2017

Allright, thanks for the answer.

@rjong rjong closed this as completed Jul 27, 2017
@RishabhTayal
Copy link

RishabhTayal commented Mar 23, 2018

@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.

@RishabhTayal
Copy link

RishabhTayal commented Mar 23, 2018

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
}

@bialabs
Copy link

bialabs commented Jun 23, 2022

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants