
我知道这个reg_ID可以随时过期,因为谷歌说它可以.从文档中可以清楚地看到如何检查ID是否仍然正常,并且它是一个很大的IF,我再次启动应用程序.但是,为什么我或任何其他用户再次启动它?在清单中注册的GCMIntentService根据需要在那里收集消息,并且无需出于任何原因再次运行应用程序.因此,当ID到期时,我将停止获取消息 – 服务器可能从返回代码中知道,但无法通知我的应用程序 – 无法恢复,除非我再次运行应用程序并通过其onCreate()并且可能registerClIEnt()方法.
那么当ID到期时会发生什么?我没有看到IntentService中的任何on ..方法都会执行.谷歌自己会发一条正常消息说它即将到期吗?我是否需要编写一个每天运行的警报任务并检查ID?
@R_403_6120@ 根据 GCM:An existing registration ID may cease to be valID in a number of
If the application manually unregisters by issuing a com.Google.androID.c2dm.intent.UNREGISTER intent. If the application is automatically unregistered,which can happen (but is not guaranteed) if the user uninstalls the application. If the registration ID expires. Google might decIDe to refresh registration IDs. If the application is updated but the new version does not have a broadcast receiver configured to receive com.Google.androID.c2dm.intent.RECEIVE intents.
scenarios,including:
考虑与注册相关的响应将触发“com.Google.androID.c2dm.intent.REGISTRATION”意图.因此,您应该注意从GCM发送的注册消息.
更新
GCM doc说:
If the registration ID expires. Google might decIDe to refresh
registration IDs. For all these cases,you should remove this
registration ID from the 3rd-party server and stop using it to send
messages. Happens when error code is NotRegistered.
考虑到上述事实,然后在您的服务器上,您应该处理过期的ID并在您的数据库中设置一个标志,下次您的AndroID客户端检查您的服务器(最后您必须进行定期检查)或调用isRegisteredOnServer在GCMRegistrar类上得到错误的结果,你应该激活REGISTRATION意图以获得一个新的ID.
总结以上是内存溢出为你收集整理的android – Google Cloud Messaging(GCM)和registration_id到期,我怎么知道?全部内容,希望文章能够帮你解决android – Google Cloud Messaging(GCM)和registration_id到期,我怎么知道?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)