mac229 mac229 - 23 days ago 15
Android Question

Clearing app data not clearing GCM token nor GCM subscribing topics

I had subscribed to topics from GCM and when I removed all app data by android settings, the GCM token is the same and GCM notification on topics are still available, so I get notifications which I don't want to receive.

My questions are:


  • How can I get list all of subscribed topics from GCM?

  • How can I remove all subscribed topics without knowing their names?

  • Should the GCM token be changed after clearing app data or should all subscribed topics be removed automatically in this case?


Answer
  1. You can't only you can use tool for debug i suggest :) You have to save subscribed topics for example in sharedprefs. If you don't have token in sharedpreferences you should call instanceId.deleteInstanceID()

  2. Simply call instanceId.deleteInstanceID()

  3. Token will change rarely but when it changes you must resubscribe all your topics.

Also checkout this question on SO


TOOL

You can use this tool to debug :)

When i don't subscribe any topic i get something like this:

{
    "applicationVersion": "39",
    "connectDate": "2016-01-12",
    "application": "com.esportlivescore.develop.debug",
    "authorizedEntity": "11443413691531",
    "connectionType": "MOBILE",
    "appSigner": ".................",
    "platform": "ANDROID"
}

After i subscribe some topic:

{
    "applicationVersion": "39",
    "connectDate": "2016-01-12",
    "application": "com.esportlivescore.develop.debug",
    "authorizedEntity": "11443413691531",
    "rel": {
        "topics": {
            "match-28388-start": {
                "addDate": "2016-01-13"
            }
        }
    },
    "connectionType": "MOBILE",
    "appSigner": ".................",
    "platform": "ANDROID"
}

So somple usage. I use Advanced REST Client (plugin for Chrome)

HTTP GET Request

https://iid.googleapis.com/iid/info/<TOKEN>?details=true
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

TOKEN in url : token obtainet from google

key : can be found in Google Developer Console / GCM Console

enter image description here