Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting app from a device doesn't clear NSUserDefaults

Tags:

ios

iphone

I'm storing a value in NSUserDefaults that I use to check if it's the first time the app has been launched. I check this value in my App Delegate and it works fine for the most part. However, I expected that this value would clear if I deleted the app from the device so that when launched the first time after being reinstalled it would behave as though it had never been installed on that device. However, the value stored in NSUserDefaults is still there. Now I know how to clear NSUserDefaults programmatically but how would I do this and still be able to tell if it's the first time the app has been launched (and have the first time launched after being deleted be detected as a first launch)?

Edit: This issue was for an actual physical device (not the simulator). Deleting the app from the simulator DID clear NSUserDefaults correctly. However, I had my iPhone replaced yesterday and the new phone doesn't exhibit this issue. NSUserDefaults is clearing correctly now. Don't know what fixed the problem but I'll take it.

like image 929
Rachid Avatar asked Sep 17 '14 08:09

Rachid


People also ask

Is Userdefault deleted app deleted?

UserDefaults will not be deleted after uninstalling the application.

When you delete an app does it delete all the data?

When you delete an app, the app and its data are removed from your device. If you want to remove the app, but keep its data, you can offload the app instead.


1 Answers

For anyone facing the same issue on device.

If you have more than 1 app under the same group and all of them are using app groups (ON under capabilities), then you will have to remove all the apps from the device in order for the user defaults to be cleared.

Since the user defaults are shared, even if one of the app is on the device then it will not be deleted, as that app will be using the userdefaults.

like image 96
Ankit Srivastava Avatar answered Oct 18 '22 17:10

Ankit Srivastava