java - 如何重置设备的 Google Cloud Messaging 注册?

标签 java android push-notification google-cloud-messaging

我在手机中为我的应用程序实现 gcm 时犯了一个错误,现在它没有收到任何通知。同一个应用程序在任何其他设备上都能完美运行(接收 gcm 通知)。我需要从 gcm 中取消注册我的手机,我应该怎么做?

我应该等待 7 天(默认到期时间)吗?

最佳答案

您可以针对单个设备尝试以下注销过程(卸载应用程序并稍后重新安装)。 (注意,这是来自 Google Cloud Messaging 高级文档 here )

How unregistration works

An application can be automatically unregistered after it is uninstalled from the device. However, this process does not happens right away, as Android does not provide an uninstall callback. What happens in this scenario is as follows:

  1. 最终用户卸载应用程序。
  2. 第 3 方服务器向 GCM 服务器发送消息。
  3. GCM 服务器将消息发送到设备。
  4. GCM 客户端收到消息并查询包管理器是否配置了广播接收器来接收它,结果返回 false。
  5. GCM 客户端通知 GCM 服务器 > 应用程序已卸载。
  6. GCM 服务器标记要删除的注册 ID。
  7. 第 3 方服务器向 GCM 发送消息。
  8. GCM 向第 3 方服务器返回 NotRegistered 错误消息。
  9. 第 3 方删除注册 ID。

Note: The GCM client is the Google Cloud Messaging framework present on the device.

Note that it might take a while for the registration ID be completely removed from GCM. Thus it is possible that messages sent during step 7 above gets a valid message ID as response, even though the message will not be delivered to the device. Eventually, the registration ID will be removed and the server will get a NotRegistered error, without any further action being required from the 3rd-party server (this scenario happens frequently while an application is being developed and tested).

关于java - 如何重置设备的 Google Cloud Messaging 注册?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25240974/

相关文章:

java - 如果我使用 save,为什么 saveOrUpdate 在执行时不会在数据库中插入注释

java - GWT 中的 ClientBundles 和代码拆分?

java - 如何使用带有内容的 spring boot Controller 下载 csv 文件?

ios - 推送通知 -didFinishLaunchingWithOptions

silverlight - Windows Phone 7 推送通知未显示在我的手机上

java - 什么 html 解析器能够处理编码?

java - 如何滑动删除卡片(使用 appcompat v7 的 CardView)

android - 选择其他单选按钮时,单选按钮组中的单选按钮不会取消选择

java - 如何使用Java上传图像Url上传到Fire Storage并同时将其保存在fireStore中

android - 使用通知导航到带有 navArgs 的 fragment