matthewpalmer / Locksmith

A powerful, protocol-oriented library for working with the keychain in Swift.
MIT License
2.92k stars 266 forks source link

How to clear data when app is uninstalled? #96

Open transcope opened 8 years ago

transcope commented 8 years ago

Does Locksmith have function used to delete everything from app's Keychain?

When app is uninstalled, how can I clear app's keychain made by locksmith?

Thank u very much

matthewpalmer commented 8 years ago

It used to, but got removed in the 2.0 rewrite. Would love to see it added back in if you have time to open a PR :)

On 23 Dec 2015, at 8:46 PM, jasonji84 notifications@github.com wrote:

Does Locksmith have function used to delete everything from app's Keychain?

When app is uninstalled, how can I clear app's keychain made by locksmith?

Thank u very much

— Reply to this email directly or view it on GitHub.

cwagdev commented 8 years ago

Even if such a method existed, as far as I know you wouldn't be able to run it when the app is uninstalled. This is one strange thing about the iOS Keychain.

thatjuan commented 7 years ago

@cwagdev The keychain probably persists because it is available to all of the user's devices. Uninstalling an app from one device shouldn't remove any keychain data because the user may have that same app in other devices.

If I'm correctly assuming that your main concern is that values are coming back after you re-install your app, then you can avoid that using this workaround:

You can use NSUserDefaults to detect your app's first launch. If the app has launched for the first time, then you can either ignore whatever's in keychain and over-write it or you can delete the values (keeping in mind they'll vanish from any other user devices too).