清除未清除GCM令牌的应用程序数据,也不清除GCM订阅主题 [英] Clearing app data not clearing GCM token nor GCM subscribing topics

查看:144
本文介绍了清除未清除GCM令牌的应用程序数据,也不清除GCM订阅主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经订阅了GCM的主题,当我通过android设置删除所有应用数据时,GCM令牌是相同的,并且主题的GCM通知仍然可用,因此我收到了我不想接收的通知。 / p>

我的问题是:


  • 如何获取列出所有订阅的主题GCM?

  • 如何在不知道名称的情况下删除所有订阅的主题?

  • GCM令牌在清除应用数据后应该更改还是应该全部订阅在这种情况下会自动删除主题?


解决方案


  1. 你不仅可以使用工具进行调试,我建议:)
    你必须在sharedprefs中保存订阅的主题。如果您在sharedpreferences中没有标记,您应该调用 instanceId.deleteInstanceID()


  2. instanceId.deleteInstanceID()


  3. 令牌很少发生变化,但当它发生变化时,您必须重新订阅所有主题。

同时结帐


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?

解决方案

  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

这篇关于清除未清除GCM令牌的应用程序数据,也不清除GCM订阅主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆