I'm using the new google cloud messaging
(GoogleCloudMessaging gcm =
GoogleCloudMessaging.getInstance (context);)
I am following this example, which is very good and works perfectly:
https://github.com/commonsguy/cw-omnibus/tree/master/Push/GCMClient2
With this example I can register in the GCM, but I tried unsuccessfully to unregister.
in the documentation indicates that you should use the following intent:
com.google.android.c2dm.intent.UNREGISTER
And use it as follows:
Intent unregIntent = new Intent ("com.google.android.c2dm.intent.UNREGISTER");
unregIntent.putExtra ("app", PendingIntent.getBroadcast (this, 0, new Intent (), 0));
StartService (unregIntent);
not working ...
As I said, the register works fine, but do not know how to unregister.
I have to do more than the intent? What am I doing wrong?
I appreciate any help
Thanks and regards
If you are using the new GoogleCloudMessaging
class, you don't need to use the com.google.android.c2dm.intent.UNREGISTER
intent. Simply use GoogleCloudMessaging.unregister().
public void unregister ()
Unregister the application. Calling unregister() stops any messages from the server. This is a blocking call—you shouldn't call it from the UI thread. You should rarely (if ever) need to call this method. Not only is it expensive in terms of resources, but it invalidates your registration ID, which should never change unnecessarily. A better approach is to simply have your server stop sending messages. Only use unregister if you want your application to stop using GCM permanently, or you have a compelling reason to recycle your registration ID.
Throws
IOException if we can't connect to server to unregister.
Unregistration may take up to 5 minutes to propagate.
https://developer.android.com/google/gcm/adv.html#unreg-why
Old Way (Deprecated):
public synchronized void unregister()
New Way (Instead use):
InstanceID.deleteToken();
or
InstanceID.deleteInstanceID();
Unregister the application. Calling unregister() stops any messages
from the server. This is a blocking call—you shouldn't call it from
the UI thread. You should rarely (if ever) need to call this method.
Not only is it expensive in terms of resources, but it invalidates all
your registration IDs returned from register() or subscribe(). This
should not be done unnecessarily. A better approach is to simply have
your server stop sending messages.