• <tfoot id='2N30b'></tfoot>
    <legend id='2N30b'><style id='2N30b'><dir id='2N30b'><q id='2N30b'></q></dir></style></legend>

        <bdo id='2N30b'></bdo><ul id='2N30b'></ul>
      <i id='2N30b'><tr id='2N30b'><dt id='2N30b'><q id='2N30b'><span id='2N30b'><b id='2N30b'><form id='2N30b'><ins id='2N30b'></ins><ul id='2N30b'></ul><sub id='2N30b'></sub></form><legend id='2N30b'></legend><bdo id='2N30b'><pre id='2N30b'><center id='2N30b'></center></pre></bdo></b><th id='2N30b'></th></span></q></dt></tr></i><div id='2N30b'><tfoot id='2N30b'></tfoot><dl id='2N30b'><fieldset id='2N30b'></fieldset></dl></div>
    1. <small id='2N30b'></small><noframes id='2N30b'>

      1. 何时为用户注册 FCM 令牌

        时间:2023-07-30

        <i id='fT7t3'><tr id='fT7t3'><dt id='fT7t3'><q id='fT7t3'><span id='fT7t3'><b id='fT7t3'><form id='fT7t3'><ins id='fT7t3'></ins><ul id='fT7t3'></ul><sub id='fT7t3'></sub></form><legend id='fT7t3'></legend><bdo id='fT7t3'><pre id='fT7t3'><center id='fT7t3'></center></pre></bdo></b><th id='fT7t3'></th></span></q></dt></tr></i><div id='fT7t3'><tfoot id='fT7t3'></tfoot><dl id='fT7t3'><fieldset id='fT7t3'></fieldset></dl></div>

              <tfoot id='fT7t3'></tfoot>

              <small id='fT7t3'></small><noframes id='fT7t3'>

              <legend id='fT7t3'><style id='fT7t3'><dir id='fT7t3'><q id='fT7t3'></q></dir></style></legend>
                <tbody id='fT7t3'></tbody>
                <bdo id='fT7t3'></bdo><ul id='fT7t3'></ul>

                1. 本文介绍了何时为用户注册 FCM 令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我对在我的应用中实施 Firebase 云消息传递有些疑问.

                  I have some doubts about implementing Firebase Cloud Messaging in my app.

                  我的应用是一个类似于 whatsappfacebook messenger 的聊天应用.现在每次有人登录时,我都会注册令牌并将其与用户相关联.因此,如果有人想与用户聊天,应用程序会在 Db 中搜索用户 ID,而我有他的令牌.

                  My app is a chat similar to whatsapp and facebook messenger. Right now every time someone logs in I register the token and relate it to the user. So if someone wants to chat to an user the app searches the Db for the user ID and there I have his token.

                  我可以注册设备令牌,但我不确定何时应该这样做.

                  I'm able to register the device token but I'm not sure when should I do that.

                  在我的聊天中,用户通过邮件/密码注册进行注册,并且有可能用户可以在其他设备上登录.

                  In my chat users register through a mail/password signup and is possible that an user could login in other device.

                  例如:用户 Frehley 使用 Galaxy 8 并且能够使用令牌在他的设备中聊天和接收通知.但是可以说他登录了另一个设备.我需要重新注册令牌并将其与他关联对吗?

                  For example: User Frehley uses a Galaxy 8 and is able to chat and receive notifications in his device using the token. But lets say that he loges in another device. I need to register the token again and relate it to him right?

                  所以,也许我错了,但注册令牌的最佳时机是每次用户登录并在数据库中替换它时.对吧?

                  So, maybe I'm wrong but the best moment to register the token is every time the user logs in and replace it in the DB. Right?

                  现在,假设两个用户(Frehley 和 Stanley)使用相同的 Galaxy 8 登录,每次登录时令牌都会不同,还是每个设备都相同?

                  Now, lets say two users (Frehley and Stanley) uses the same Galaxy 8 to login, the token will be diferent everytime the login or it is the same for every single device?

                  推荐答案

                  这一切都取决于用例:

                  • 如果同一用户登录到两台设备,您是否希望他们在两台设备上都收到通知?如果是这样,您需要为每个用户存储多个设备令牌并将通知发送到目标用户的每个令牌.您还可以使用设备组来识别单个用户的设备.从这些文档中:

                  借助设备群组消息,您可以向在属于某个群组的设备上运行的应用程序的多个实例发送一条消息.通常,组"是指属于单个用户的一组不同设备

                  With device group messaging, you can send a single message to multiple instances of an app running on devices belonging to a group. Typically, "group" refers a set of different devices that belong to a single user

                2. 如果您希望用户仅在他们上次使用的设备上收到通知,则您必须将单个令牌与每个用户相关联,并在他们在设备上启动应用程序时覆盖该令牌.并不是说这不一定是在他们登录时,而是在应用 检测到它们已通过身份验证.

                  如果不同的用户在同一设备上使用同一应用(使用相同的设备配置文件),您可能希望停止向设备令牌发送.最可靠的方法是删除前一个用户和令牌之间的关联,但这可能需要您保留从令牌到 UID 的映射.更简单的方法是删除设备令牌 当用户退出时.然后新用户登录,他们将获得一个新的令牌.

                  If a different user uses the same app on the same device (using the same device profile), you probably want to stop sending to the device token. The most robust way to do this is to remove the association between the previous user and the token, but that may require that you keep a mapping from token to UID. An easier way is to delete the device token when a user signs out. Then the new user signs in, they will then get a new token.

                  这篇关于何时为用户注册 FCM 令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                3. 上一篇:从后台删除应用程序时,Android FCM 未收到通知 下一篇:应用程序在后台时的 Firebase 侦听器

                  相关文章

                  <i id='OxE9h'><tr id='OxE9h'><dt id='OxE9h'><q id='OxE9h'><span id='OxE9h'><b id='OxE9h'><form id='OxE9h'><ins id='OxE9h'></ins><ul id='OxE9h'></ul><sub id='OxE9h'></sub></form><legend id='OxE9h'></legend><bdo id='OxE9h'><pre id='OxE9h'><center id='OxE9h'></center></pre></bdo></b><th id='OxE9h'></th></span></q></dt></tr></i><div id='OxE9h'><tfoot id='OxE9h'></tfoot><dl id='OxE9h'><fieldset id='OxE9h'></fieldset></dl></div>

                    <tfoot id='OxE9h'></tfoot>
                    <legend id='OxE9h'><style id='OxE9h'><dir id='OxE9h'><q id='OxE9h'></q></dir></style></legend>

                    <small id='OxE9h'></small><noframes id='OxE9h'>

                      • <bdo id='OxE9h'></bdo><ul id='OxE9h'></ul>