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

<tfoot id='QXBzH'></tfoot>

      <bdo id='QXBzH'></bdo><ul id='QXBzH'></ul>

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

    1. <legend id='QXBzH'><style id='QXBzH'><dir id='QXBzH'><q id='QXBzH'></q></dir></style></legend>

        发送云消息 (FCM) 多设备单用户

        时间:2023-07-28
        <legend id='422eR'><style id='422eR'><dir id='422eR'><q id='422eR'></q></dir></style></legend>

        <small id='422eR'></small><noframes id='422eR'>

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

                1. 本文介绍了发送云消息 (FCM) 多设备单用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个已经构建好的应用程序.现在我想使用 FCM 在服务器和用户之间发送消息.据我了解,每个设备都有自己的令牌,我可以使用它来发送消息,并且可以从

                  I have an application which is already built. Now I want to use FCM to send messages between server and users. As I understand each device has its own token which I can use to send message, and this token can be retrieved from

                  FirebaseInstanceId.getInstance().getInstanceId()
                  

                  如果我错了,请纠正我.

                  Correct me If I am wrong.

                  应用程序和支持的服务器运行良好,超出了我的工作流程

                  The application and backed server works fine and bellow my workflow

                  1- 用户打开安卓应用.

                  1- User open the android app.

                  2- Android 应用使用用户令牌 ID 进行身份验证,使用设备令牌进行身份验证消息并将它们发送到服务器.

                  2- Android app take the user token ID for authentication and device token for messageing and send them to the server.

                  3-后端服务器通过

                  decodedToken = FirebaseAuth.getInstance().verifyIdToken(login.getToken()); 
                  

                  然后它保存发送消息的令牌.

                  then it save the token for sending the message.

                  在我遇到以下情况之前,发送消息工作正常.

                  Sending message working fine until I stuck with the following scenario.

                  该应用程序允许多个设备使用同一用户登录,这意味着 1 个用户可以拥有多个用于消息传递的令牌.
                  在这种情况下,我想向使用该用户登录的所有设备发送消息.

                  The application allows multiple devices to login with same user, which means for 1 USER can have multiple tokens for messaging.
                  In this case I want to send message to all devices logged in with this user.

                  那么我如何在不改变应用程序当前设计的情况下做到这一点

                  So how I can do this without changing the current design of my application

                  推荐答案

                  您需要更改数据库并添加从一个用户保存所有设备令牌的功能.然后你需要调用这个 Firebase api https://fcm.googleapis.com/fcm/send 与用户拥有的令牌一样多.这里是官方文档.

                  You need to change your DB and add ability to save all device tokens from one user. Then you need to call this Firebase api https://fcm.googleapis.com/fcm/send as many times as the tokens user have. Here the official documentation.

                  https://firebase.google.com/docs/cloud-messaging/http-server-ref

                  要在客户端更改设备特定令牌时更新它,您还必须将该令牌与 deviceID 绑定,因此您需要在传递 Firebase 令牌时将 DeviceId 传递给服务器.由于 deviceID 可以提供 Android 唯一的 deviceID,或在客户端 FirebaseInstanceId.getInstance().id 中提供 Firebase 的 id.以及这里如何获取Android deviceID

                  To update device specific token when it is changed on client side, you also have to bound that token with the deviceID, so to have that you need to pass the DeviceId to the server when passing the Firebase token. As deviceID can serve Android unique deviceID, or the id that provides Firebase in client side FirebaseInstanceId.getInstance().id. And here how to get Android deviceID

                  是否有唯一的 Android 设备 ID?

                  如果您使用 access_token 登录用户,作为另一种选择,您可以将 firebase 令牌与用户 access_token 绑定,因为它对于用户登录的任何设备都是唯一的.

                  If you use access_token for login the user, as another alternative, you can bound firebase token with user access_token, as it is unique for any device the user logged in.

                  这篇关于发送云消息 (FCM) 多设备单用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:想知道 FCM 在以下场景中的工作原理 下一篇:禁止用户订阅 Firebase 主题

                  相关文章

                  <small id='31B71'></small><noframes id='31B71'>

                  <legend id='31B71'><style id='31B71'><dir id='31B71'><q id='31B71'></q></dir></style></legend>

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

                      <tfoot id='31B71'></tfoot>