Function call when app is deleted from the device?

Is there a method that is called when an app is deleted from the iPhone/iPad? I'm talking about when a user holds an app icon, the app icon starts to move, and the user clicks the 'x' in the upper left-hand corner of the icon.

Replies

No, there's no function call or method called when your application is getting deleted (or about to get deleted).

Here's why: apps aren't supposed to care about what happens outside their containers. On OS X, there are APIs that will notify you of filesystem events like things being deleted, but even those are all but unusable now that App Sandbox is everywhere.

I find this hard to believe. It seems like Apple would want developers to have this capability. How does Apple want developers to do things when the app gets deleted? For example, I would like to manually delete some database files that are stored locally on the device. How does Apple propose I do this?

All of your app's files are deleted by the OS when the user deletes the app. If Apple wanted developers to have that capability, we would have that capability 🙂


You could make a case for needing to know the app is deleted if you are storing stuff on the server side. Currently from the server's point of view there's no way to know whether the app was deleted or the user just stopped using it. But locally stored files are not an issue.