0

Possible Duplicate:
Is it possible to detect Android app uninstall?

I am implementing c2dm service in an app in order to be able to send message to all the users. In google's c2dm documentation, it is quite well explained how to register the app to the service, and how to unregister it. But how I am supposed to unregister from c2dm, when I can not get any event when the application is uninstalled?

Community
  • 1
  • 1
AlexMok
  • 724
  • 5
  • 18

2 Answers2

1

The documentation says:

Depending on the implementation of the application, it may offer users the option of unregistering to receive messages. Uninstalling the application also has the effect of unregistering.

I'd say this means that the device will take care of this, and you don't have to worry about it..

edit: I was wrong. The device doesn't take care of this.. See: Android C2DM : Duplicate message to the same device and App

Seems like the solution is to include (a part of) your registration id in the push message, and do a check on your device

Community
  • 1
  • 1
Jolanda Verhoef
  • 609
  • 5
  • 11
  • "Uninstalling the application also has the effect of unregistering.". I do not agree with this. Because when I re-install the application, all notification are doubled. And if I uninstall/re-install again, notifications are then tripled.. So you still have to unregister. – AlexMok Nov 10 '11 at 10:52
  • Where in the documentation does it say this? In the C2DM docs, it says specifically: "The registration ID lasts until the application explicitly unregisters itself, or until Google refreshes the registration ID for your application." http://code.google.com/android/c2dm/ – Thomas Dignan Mar 30 '12 at 00:54
0

Google C2DM service is working in passive mode when it comes to detecting uninstalled applications.

First push notification after uninstalling your application (without unregistering from C2DM!!!) will NOT return any error in response. However, the second push notification will return an "invalid registration" or "not registered" error codes where you can realize the application was uninstalled.

The reason is that C2DM servers return the response code immediately and only then tries to push the client. When client respond that an application was uninstalled, it is deleted from C2DM servers. Next push attempt will return an error code immediately.

Zamel
  • 692
  • 1
  • 10
  • 21