There is no Intent
/ Receiver
or "callback" that your application can notify of its own uninstallation.
There is Broadcast
of ACTION_PACKAGE_REMOVED
1 , which is triggered for all receivers
that are registered for this Intent
, but your application is not notified 2 if they are being uninstalled.
GCM has a form of detection, and is based on the NotRegistered
status of the response of a message sending to the GCM server.
This is the only indication that the application has been uninstalled and is no longer available to receive messages. The steps are as follows 3 :
- The user uninstalls your application.
- Your server tries to send a message to the GCM server, targeting your application that has been uninstalled on a particular device.
- GCM sends the message to the device.
- The GCM Client on the device receives the message, queries
PackageManager
checking to see if it has a BroadcastReceiver
configured to accept this message, returning false to the application that has been uninstalled.
- The GCM Client notifies the GCM server that the application has been uninstalled. And the GCM server marks that
registration_id
for deletion.
- Your server tries to send a new message to the same application / device.
- GCM Server will respond to your server with a
NotRegistered
error for this message.
- Your server removes
registration_id
from the bank.
This is the only way GCM can detect uninstallation.
Take a look at the HTTP response status type, specifically in the failure
field and in the error
field of each registration_id
(which failed), it comes with the NotRegistered
value, which GCM you can submit according to documentation .
References
link
link
link