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

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

        <bdo id='tn2VU'></bdo><ul id='tn2VU'></ul>
      <legend id='tn2VU'><style id='tn2VU'><dir id='tn2VU'><q id='tn2VU'></q></dir></style></legend>
      <tfoot id='tn2VU'></tfoot>

      1. Firebase 推送通知与 childAdd 监听器

        时间:2023-07-29
          <tbody id='1ScE2'></tbody>
        • <tfoot id='1ScE2'></tfoot>
            • <bdo id='1ScE2'></bdo><ul id='1ScE2'></ul>

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

                  <small id='1ScE2'></small><noframes id='1ScE2'>

                  <legend id='1ScE2'><style id='1ScE2'><dir id='1ScE2'><q id='1ScE2'></q></dir></style></legend>
                • 本文介绍了Firebase 推送通知与 childAdd 监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在开发基于 Firebase 的移动应用的好友请求模块,因此我正在考虑选择推送通知的方式.

                  I'm working in a friend request module for mobile app base on Firebase so I'm considering to choose the way that notification is pushed.

                  假设 userA 请求与 userB 成为朋友.现在有2个想法:
                  - userA 向一个简单的服务器发送请求,然后它会调用 FCM 向 userB 发送通知.
                  - 创建一个服务来侦听 Firebase 实时数据库中更改的数据,然后 userA 将在该数据库上进行更改,并且通知将显示在 userB 设备上.

                  Assume that userA request to be friend with userB. There're 2 ideas now:
                  - userA send request to a simple server then it will call FCM to send notification to userB.
                  - Make a service that listen to data changed in Firebase realtime database then userA will make change on that db and notification will be shown on userB device.

                  我认为两者都可以实现,但哪个更好,为什么?请给我一些建议...

                  I think both are possible to implement but what is better, and why? Please give me some advice about this..

                  提前致谢.

                  推荐答案

                  使用任何一个都可以.

                  但是,这里要考虑的一点是,当实时数据库保持侦听器处于活动状态时,它还会在用户设备上保持一个打开的套接字,这会增加电池消耗.

                  However, a point to consider here is when keeping a listener active for the Real-time database, it also keeps an open socket on the user's device which adds to battery consumption.

                  而对于 FCM,它只会在需要发送通知时触发.如果 好友请求 对应用来说不是很重要,我认为使用 FCM 是一种可行的方法.

                  While for FCM, it will only trigger once there is a notification is needed to be sent. If a friend request isn't really that app critical, I think using FCM is a way to go.

                  您是否也考虑过同时使用两者?如果用户当前在线,最好使用实时数据库,但如果用户离线(例如不使用应用程序).在这种情况下,您可以设置它以便向用户发送通知.

                  Have you also considered using both? If the user is currently online, it would be good to use the Real-time DB, but the childAdded won't be triggered if the user is offline (not using the app for instance). In that case, you can set it so that a notification will be sent to the user.

                  在你的场景中重要的是好友请求应该先保存在你的数据库或应用服务器中,这样才会触发相应的动作(FCM通知或实时数据库更新).

                  The important thing in your scenario is that the friend request should be saved first in your database or app server, so that it will trigger the corresponding action (FCM notification or Real-time DB update).

                  这篇关于Firebase 推送通知与 childAdd 监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:FCM for android:应用程序在后台时弹出系统通知 下一篇:HTTP 发布请求:错误 400,Firebase 主题消息传递

                  相关文章

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

                    <legend id='c61Zl'><style id='c61Zl'><dir id='c61Zl'><q id='c61Zl'></q></dir></style></legend>

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

                    1. <tfoot id='c61Zl'></tfoot>

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