简体   繁体   English

C2DM的设备注册ID会过期吗?

[英]Would device registration id of C2DM expires?

Well, I know that the registration id of server would expire. 好吧,我知道服务器的注册ID将过期。 However, how about the device registration id? 但是,设备注册ID呢? If yes, how do the server and client know about that? 如果是,服务器和客户端如何得知?

Now I just simply save the id into database and assume it would never change. 现在,我只是将ID保存到数据库中,并假设它永远不会更改。

Btw, is the registration id of server associated with the device registration id? 顺便说一句,服务器的注册ID是否与设备注册ID相关联? Why the tutorial from the internet store them in the pair 为什么互联网上的教程将它们存储在一对中

Short answer is Yes, as stated here . 简短的回答是肯定的,说这里

The application should store this ID for later use. 应用程序应存储此ID供以后使用。 Note that Google may periodically refresh the registration ID, so you should design your application with the understanding that the REGISTRATION Intent may be called multiple times. 请注意,Google可能会定期刷新注册ID,因此您在设计应用程序时应了解可能会多次调用REGISTRATION Intent。 Your application needs to be able to respond accordingly. 您的应用程序需要能够做出相应的响应。

Basically what would have to happen is that your application needs some sort of communication with your server to notify it that it received a new id. 基本上必须要做的是,您的应用程序需要与服务器进行某种形式的通信,以通知它收到了新的ID。 What you could do is when the app receives a registration id, store it on some remote database along with some additional unique information about that device (or user credentials if app has authentication). 您可以做的是,当应用收到注册ID时,将其连同有关该设备的其他一些独特信息(如果应用具有身份验证,则为用户凭据)存储在某个远程数据库中。 When Google decides to change the registration id, just update the previous entry on the remote db with the new id. 当Google决定更改注册ID时,只需使用新ID更新远程数据库上的上一个条目即可。 Then when your server needs to push a message to some device, it matches the device to an up-to-date registration id in the database and uses that id to push the notification. 然后,当您的服务器需要将消息推送到某个设备时,它将设备与数据库中的最新注册ID相匹配,并使用该ID来推送通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM