How to delete Keychain data when app is uninstalled?

11,602

This is work around , but may be will satisfy you: Store in NSUserDefaults flag, that keychain have data. If it's NO then ignore keychain.

Share:
11,602
Paolpa
Author by

Paolpa

Updated on June 23, 2022

Comments

  • Paolpa
    Paolpa almost 2 years

    I have a problem . I am saving some critical information on device Keychain for my App, but when I uninstall the App and install it again, these data is still saved. How can delete these information when the application is uninstalled? If this is not possible, how detect when the App is first Load after install it without save information in NSUserDefaults?

    Thank you very much.

  • rckoenes
    rckoenes over 10 years
    NSUserDefault are not secure, it makes more sense to store it in a more save place like he KeyChain since the NSUserDefault are just stored as plain text.
  • Jeffery Thomas
    Jeffery Thomas over 10 years
    @rckoenes I updated my answer. I think you want to use Data Protection.
  • Paolpa
    Paolpa over 10 years
    Thank you Jeffery Thomas, very good alternative!
  • orkoden
    orkoden about 10 years
    You should not use NSUserDefaults for sensitive data like passwords or certificates.
  • Cy-4AH
    Cy-4AH about 10 years
    @orkoden, anybody have said about storing passwords in NSUserDefaults? I am not.
  • Cy-4AH
    Cy-4AH over 9 years
    @ta.speot.is. Thank you cap. Why -1?
  • Cy-4AH
    Cy-4AH over 9 years
    @ta.speot.is, Have you minused answer in stackoverflow.com/questions/4747404/…? It's the same, but shorter.
  • ta.speot.is
    ta.speot.is over 9 years
    Sorry, I misread your answer. I can't take back my downvote because I downvoted you a few hours ago, but if you make a small edit to your answer I can upvote it.
  • ChuckZHB
    ChuckZHB almost 3 years
    I disagree to save critical information in UserDefaults.