为什么在应用程序更新时重新注册到 gcm? [英] Why re-register to gcm when application gets updated?

查看:18
本文介绍了为什么在应用程序更新时重新注册到 gcm?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用 gcm.在 Google Developers Console 页面中,我创建了一个项目并获得了一个项目 ID:

I am using gcm in my application. In Google Developers Console page, I created a project and obtained a project id:

在我的应用程序中使用此项目 ID,用户将注册到 gcm 服务器并获得注册 ID.然后将其发送到我的第 3 方服务器进行存储.

Using this project id in my application, the user gets registered to the gcm servers and obtain a registeration id. Then it is sent to my 3rd party server to be stored.

当第 3 方服务器想要向用户发送消息时,它会使用我在 Google Developer Console 页面中发布操作的标题中获得的 apikey,并使用为该特定用户存储的注册 ID.我使用的 api 密钥来自:

When 3rd party server wants to send message to the user, it uses the apikey I've obtained in the Google Developer Console page in the header of the post action and uses ther registeration id that has been stored for this particular user. The api key I'm using is from:

请注意,这是服务器应用程序的关键,我使用这些信息的方式正如我所解释的那样.

Please note that it's the key for server applications and the way i'm using this information is as just as I explained.

一切正常,消息由正确的用户检索,等等.我打算在 google play 上部署我的应用程序,但该部分中写的是:GCM 高级主题 让我感到困惑.它说:

Everything works fine, messages are retrieved by the correct users and so on.I'm planning to deploy my app on google play but what is written in the section:GCM advanced topics confuses me. it says :

当应用程序更新时,它应该使其现有的注册 ID 无效,因为它不能保证与新版本一起使用

When an application is updated, it should invalidate its existing registration ID, as it is not guaranteed to work with the new version

以及实现GCM客户端中示例代码的注释部分示例代码有这样的评论:

// Check if app was updated; if so, it must clear the registration ID
// since the existing regID is not guaranteed to work with the new
// app version.

这两种解释是什么意思?我想除非我在这里按下再生键:

What is meant by these two explanations? I thought unless I press regenerate key here:

我的 api 密钥不会改变.当我更新我的应用程序时,为什么它(或它真的)会改变?还是我做错了什么?

my api key wouldn't change. Why should it (or does it really) change when I update my application? or am I getting something wrong?

推荐答案

您混合了两个不同的术语 - API 密钥和注册 ID.部署新版本时,您无需创建新的 API 密钥.

You are mixing between two different terms - API key and Registration ID. You don't have to create a new API key when deploying a new version.

Google 建议做的事情(在您上面引用的引号中)是将安装新版本的每个设备重新注册到 GCM(而不是依赖先前获得的注册 ID),因为分配给 GCM 的现有注册 ID不保证您的应用程序的设备适用于新版本的应用程序.

What Google recommend to do (in the quotes you included above) is to re-register each device that installs the new version to GCM (and not rely on a previously obtained Registration ID), because the existing Registration ID assigned to the device for your application is not guaranteed to work for the new version of the app.

这篇关于为什么在应用程序更新时重新注册到 gcm?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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