gpt4 book ai didi

android - 为什么在更新应用程序时重新注册到 gcm?

转载 作者:搜寻专家 更新时间:2023-11-01 08:00:40 25 4
gpt4 key购买 nike

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

Google Developers Console Project Number image

在我的应用程序中使用这个项目 ID,用户注册到 gcm 服务器并获得一个注册 ID。然后它被发送到我的第 3 方服务器进行存储。

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

Google Developers Console Page API key image

请注意,它是服务器应用程序的 key ,我使用此信息的方式正如我所解释的那样。

一切正常,消息被正确的用户检索等等。我打算在 google play 上部署我的应用程序,但在以下部分中写了什么:GCM advanced topics让我困惑。它说:

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

以及 Implementing GCM client sample code 中示例代码的注释部分有这样的评论:

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

这两个解释是什么意思?我想除非我在这里按下重新生成键:

Google Developers Console Renegerate Key Image

我的 api key 不会改变。当我更新我的应用程序时,为什么它应该(或者它真的)改变了?还是我弄错了什么?

最佳答案

您混合使用了两个不同的术语 - API key 和注册 ID。部署新版本时,您不必创建新的 API key 。

谷歌建议做的(在你上面的引号中)是重新注册每台安装新版本到 GCM 的设备(而不是依赖以前获得的注册 ID),因为现有的注册 ID 分配给不保证适用于您的应用程序的设备适用于新版本的应用程序。

关于android - 为什么在更新应用程序时重新注册到 gcm?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21741183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com