GCM规范ID应该更新与否 [英] gcm canonical id should be updated or not

查看:178
本文介绍了GCM规范ID应该更新与否的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作,它采用的GCM Android项目。我才知道,如果我们卸载appfrom设备并重新安装大部分时间的设备被新注册id.Then如果不删除应用程序服务器和更新旧的,该消息将被发送到两个ID和在对此,就会呈现出典型的id是present.My问题是,在这一点上的信息将被成功发送到该设备或不?

I am working on an android project which uses gcm. I came to know that if we uninstall the appfrom device and reinstalled most of the time the device gets new registration id.Then if we do not delete the old one from application server and update, The messages will be sending to both ids and in the response it will be showing canonical id is present.My question is, at this point message will be successfully send to that device or not?

推荐答案

当您从谷歌的响应收到一个规范的注册ID,该消息是由GCM服务器接受,GCM服务器会尝试将其传送到设备。无论是实际发送到设备依赖于设备是否可用(即,连接到互联网)。
所以,如果你的服务器发送一个消息GCM既旧的标识,新标识,该设备可能会得到两个消息。

When you receive a canonical registration ID in the response from Google, the message was accepted by the GCM server and the GCM server would attempt to deliver it to the device. Whether it is actually sent to the device depends on whether the device is available (i.e. connected to the internet). So if your server sends a GCM message to both the old ID and the new ID, the device will probably get two messages.

规范标识

在服务器端,只要在应用程序表现良好,
  一切都应该正常工作。但是,如果在应用程序中的一个错误
  触发多个登记为同一装置,也可以是难以
  调和状态和你可能会重复的消息结束了

On the server side, as long as the application is behaving well, everything should work normally. However, if a bug in the application triggers multiple registrations for the same device, it can be hard to reconcile state and you might end up with duplicate messages.

GCM提供了一个名为规范注册ID来轻松设施
  从这些情况中恢复。一个规范的注册ID被定义
  为您的应用程序所要求的最后注册的ID。
  这是将消息发送到服务器时应该使用的ID
  设备。

GCM provides a facility called "canonical registration IDs" to easily recover from these situations. A canonical registration ID is defined to be the ID of the last registration requested by your application. This is the ID that the server should use when sending messages to the device.

如果您稍后尝试使用不同的注册发送消息
  的ID,GCM将处理该请求如常,但将包括
  在的的registration_id领域规范注册ID
  响应
。请务必将存储在注册ID的
  服务器与此规范的ID,如最终ID你用意志
  停止工作。

If later on you try to send a message using a different registration ID, GCM will process the request as usual, but it will include the canonical registration ID in the registration_id field of the response. Make sure to replace the registration ID stored in your server with this canonical ID, as eventually the ID you're using will stop working.

来源

您可以通过为您的应用程序的每个实例分配一个唯一的标识符克服这个问题。如果您存储在设备的外部存储该标识符,它不会被当应用程序卸载删除。然后,当再次安装该应用程序,你可以恢复它。如果您使用的注册ID一起发送这个标识符到你的服务器,你可以检查你的服务器有此标识的旧注册ID,并删除它。

You can overcome this problem by assigning a unique identifier to each instance of your application. If you store that identifier in the device's external storage, it won't be deleted when the app is uninstalled. Then you can recover it when the app is installed again. If you send this identifier to your server along with the registration ID, you can check if your server has an old registration ID for this identifier, and delete it.

这篇关于GCM规范ID应该更新与否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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