I am using idandersen’s scifihifi-iphone code for keychain and save password using
[SFHFKeychainUtils storeUsername:@"User" andPassword:@"123"
forServiceName:@"TestService" updateExisting:YES error:&error];
When I delete the application from the device, the password remains in the keychain.
I want to remove the password from the keychain when the user deletes the application from the device. How can I do this?
You can take advantage of the fact that
NSUserDefaultsare cleared by uninstallation of an app. For example:This checks for and sets a “FirstRun” key/value in
NSUserDefaultson the first run of your app if it’s not already set. There’s a comment where you should put code to delete values from the keychain. Synchronize can be called to make sure the “FirstRun” key/value is immediately persisted in case the user kills the app manually before the system persists it.