GCM注册ID的持久性 [英] Persistance of gcm registration id

查看:157
本文介绍了GCM注册ID的持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做的,它使用gcm.I一个Android应用程序才知道,当应用程序被卸载并安装再没有保证接收相同的注册ID again.So我所做的是在登录时我需要一个独特的从应用服务器ID,每当新的注册ID是由我能够取代应用server.So我的问题是什么,我不使用更换最新的注册ID在GCM server.Will造成任何问题的规范ID?请帮我。


解决方案

  

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


  
  

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


  
  

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


来源: http://developer.android.com/google/gcm/ adv.html#规范

I am doing an android application which uses gcm.I came to know that when the application is uninstalled and re installed there is no guarantee to receive the same registration id again.So what I did is while logging in I take one unique Id from application server and whenever new registration id is made I am able to replace that in application server.So what my question is, I am not using the canonical id for replacing the latest registration id in gcm server.Will it cause any problem? Please help me.

解决方案

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 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.

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.

Source : http://developer.android.com/google/gcm/adv.html#canonical

这篇关于GCM注册ID的持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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