4

I am new to iOS development and working on keychain storage. In my app, I would like to save some important information in iOS keychain (not shared keychain).

I don't know whether keychain data wipes out on app uninstall or not. I am looked at some blogs/stack overflow posts, but I didn't find any official apple documentation mentioning this specific information. I would like to know,

  1. Is my stored data deleted on app uninstall?
  2. What happens if user uninstall and immediately install app again? Will he get previously stored data?
Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
Kapil
  • 133
  • 2
  • 11
  • 1
    [this](https://stackoverflow.com/questions/18911434/will-items-in-ios-keychain-survive-app-uninstall-and-reinstall) seems similar question. – TheCodeTalker Feb 22 '20 at 06:34

2 Answers2

1

1. Is my stored data deleted on app uninstall? No, It will remain in keychain even after uninstallation. If you don't want you can get that behaviour with a little trick with use default to know if it's first installed or not.

What happens if the user uninstalls and immediately install app again? Will he gets previously-stored data? Only keychain data retain. Not the data in App Sandbox e.g user defaults, document directory, core data etc

SuryaKantSharma
  • 1,113
  • 12
  • 27
-1

You can use KeyChain to store, and this will not remove even if the user uninstalls your app.

        let id = KeyChain.createUniqueID()
        let data = id.data(using: String.Encoding.utf8)
        let status = KeyChain.save(key: "yourKey", data: data!)
        print(status)
AbhiRaz
  • 132
  • 2
  • 12