Detect iOS application about to delete?

No such thing, sorry.

The best you can do is do is check for the UIApplicationWillTerminateNotification notification but more importantly save the state of your app (on a server for example) when it’s transitioning to the background and cross your fingers your user will not delete your app when it’s not running. Because once your app closed, you don’t have any control anymore.

EDIT: Since you want to clear the keychain’s content when the app is deleted, I suggest you take a look at this other question. Basically, what is suggested by some answers there is not to remove the content of the keychain at delete time, but instead when the user first launches the app using NSUserDefaults.

EDIT: Luis Ascorbe commented with an idea: using Push Notification’s feedback service ( https://stackoverflow.com/a/7912045/157401 ) Of course, that’s far from perfect (not all users subscribe to the notifications, notification tokens might be invalidated for other reasons, etc.) but that’s still something to consider.

EDIT: Starting with iOS 10.3 Beta 2, keychain data appears to no longer be persisted when an app is deleted.

Leave a Comment