mac229
mac229

Reputation: 4849

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:

Upvotes: 1

Views: 2662

Answers (2)

Gelldur
Gelldur

Reputation: 11558

  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": "114434000000000",
    "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

Upvotes: 2

Bob Snyder
Bob Snyder

Reputation: 38299

How can I get list all of subscribing topics from gcm?

The current version of GCM doesn't provide a method to do this.

How can I remove all of subcribing topics without knowing their names?

The documentation indicates InstanceId.deleteInstanceID() will do this.

Should GCM token be changed after clear app data or removed all subscribing topics in this case automatically?

Although the documentation implies that token registrations and subscriptions are removed if the user clears app data, that is not true in the current version of GCM. The issue is discussed in the answer to this related question.

Upvotes: 1

Related Questions