gpt4 book ai didi

android - 从同一设备多次在 gcm 上注册将在同一设备上生成多个 id 或相同和多个用户

转载 作者:行者123 更新时间:2023-11-30 00:41:35 27 4
gpt4 key购买 nike

我想知道如果我从同一台设备在 gcm 上多次注册我的 android 应用程序,我会每次获得不同的注册 ID 还是一次注册后获得相同的注册 ID?

下面是我的第二个问题

  • 如果用户 1 注销并且用户 2 在同一设备上登录应用程序。现在假设从服务器发送给 user1 的通知。如果是,user2 是否会收到该通知,那么如何避免?

  • 如果用户 1 已登录应用程序,但用户 2 重新安装应用程序并登录,但服务器仍认为用户 1 已登录该设备,因此当我们向用户 1 发送通知时,它将被传递给用户 2。如何处理这些问题?

  • 如果我的 andriod 应用程序尝试在 gcm 上注册多次,它会得到吗不同的注册 ID 还是相同的?

最佳答案

据我所知,这将由 GCM 处理,但如本 forum 中所述解决方案是在客户端过滤它们。您的 GCM 通知应该传递给哪个用户。然后在您的 onReceive 方法中,您应该检查当前登录的用户。

关于您的最后一个问题,根据文档 - Registering:Client Apps

If a bug in the client app triggers multiple registrations for the same device, it can be hard to reconcile state and the client app might end up with duplicate messages.

Implementing canonical IDs can help you more easily recover from these situations. A canonical registration ID is the registration token of the last registration requested by the client app . This is the ID that the server should use when sending messages to the device.

If you try to send a message using an old registration token, GCM will process the request as usual, but it will include the canonical ID in the registration_id field of the response. Make sure to replace the registration token stored in your server with this canonical ID, as eventually the old registration token will stop working.

关于android - 从同一设备多次在 gcm 上注册将在同一设备上生成多个 id 或相同和多个用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42485469/

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