Android: How to find if a user has uninstalled the application

In the apps world, uninstall is a very common phenomenon, especially in Android, where there are no checks before an app gets published.

So how do you find if a particular user has uninstalled your application, a quick answer is GCM. Lets look at what happens when you send a push to a device where your application has been uninstalled.. (picked up from GCM docs)

  1. The end user uninstalls the application.
  2. Your server sends a message to GCM server.
  3. The GCM server sends the message to the device.
  4. The GCM client receives the message and queries Package Manager about whether there are broadcast receivers configured to receive it, which returns false.
  5. The GCM client informs the GCM server that the application was uninstalled.
  6. The GCM server marks the registration ID for deletion.
  7. The 3rd-party server sends a message to GCM.
  8. The GCM returns a NotRegistered error message to your server.
  9. Your server should delete the registration ID.

So from the above steps, it’s easy to understand that if your server gets “NotRegistered” error message, then the app has been uninstalled on the user’s device. So all you need to do is, send a silent push to your application, to check if it exists on user’s device.

Though from my personal experience, GCM server doesn’t return the error message even the app has been uninstalled, at least for the first few days of uninstallation.My guess is that GCM server takes some time to update the information of app uninstallation.

A more accurate approach will be to receive an ack from the application for the push message, So, if you receive an ack then the app still exists, if you don’t then the app doesn’t exist on the user’s device. But, there is a catch here, what if the app exists on the user’s device but the message is not delivered because the user isn’t connected with internet. How long will you wait to receive the ack, here is where your conscience comes to the rescue, you have to decide the time you will wait for the ack and decide if the app exists on user’s device. If your app is dependent on internet for the app usage and you don’t receive an ack with in 3-4 days, it’s safe to assume the user is useless to you whether he has the app or not, you can safely put him under uninstall category.

Identifying the uninstallation details can help you find some insights about the app if you can map user’s information with device information.

Happy Coding…