12

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.

Shaik Riyaz
  • 10,661
  • 7
  • 50
  • 69
Paolpa
  • 319
  • 2
  • 5
  • 10
  • 1
    http://stackoverflow.com/q/4747404/653513 – Rok Jarc Jan 03 '14 at 12:57
  • 2
    Why don't you want to use NSUserDefaults to store whether or not your application is started for the first time? – tilo Jan 03 '14 at 13:00
  • you cannot do anything when the application is removed from the device, the application won't be notified about that event. – holex Jan 03 '14 at 13:03
  • Because I am saving critical information and I don't want that someone can edit the preferences plist with any program as iExplorer. If someone change any value the consequences could be very bad – Paolpa Jan 03 '14 at 13:04
  • @Paolpa, in that case, you should use some encryption then... e.g. _AES256_ is good enough to protect your critical information. – holex Jan 03 '14 at 13:06
  • Theoretically keychain is safe enough, right? – Paolpa Jan 03 '14 at 13:09
  • 1
    @Paolpa, you problem is here not the safety, your original problem was about you want to delete information when the application is deleted/uninstalled; which is not possible. – holex Jan 03 '14 at 13:18

2 Answers2

5

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.

Shaik Riyaz
  • 10,661
  • 7
  • 50
  • 69
Cy-4AH
  • 4,228
  • 2
  • 14
  • 21
0

I'm not sure why you would not want to use NSUserDefaults. It seems ideal for this purpose.

Barring NSUserDefaults, you could write a file to the Documents directory and use the existence of this file as your flag.


I think I misunderstood your question. I assume the whole time you would use the keychain to store the secure value.

Use a flag in NSUserDefaults to signal that you need to delete the keychain on first launch.


As a real alternative to Keychain, use the Data Protection entitlement.

Jeffery Thomas
  • 41,379
  • 8
  • 92
  • 115