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

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

        <tfoot id='IhwFq'></tfoot>
      1. Android:FCM中接收消息的延迟(onMessageReceived)

        时间:2023-07-29
      2. <i id='dav0e'><tr id='dav0e'><dt id='dav0e'><q id='dav0e'><span id='dav0e'><b id='dav0e'><form id='dav0e'><ins id='dav0e'></ins><ul id='dav0e'></ul><sub id='dav0e'></sub></form><legend id='dav0e'></legend><bdo id='dav0e'><pre id='dav0e'><center id='dav0e'></center></pre></bdo></b><th id='dav0e'></th></span></q></dt></tr></i><div id='dav0e'><tfoot id='dav0e'></tfoot><dl id='dav0e'><fieldset id='dav0e'></fieldset></dl></div>

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

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

                <tbody id='dav0e'></tbody>
                  <bdo id='dav0e'></bdo><ul id='dav0e'></ul>
                • 本文介绍了Android:FCM中接收消息的延迟(onMessageReceived)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在测试应用中,我实现了 FCM 以使用

                  发送通知消息

                  但在我的模拟器中,我在 9:06 PM

                  收到了消息

                  如果有什么办法可以减少延迟,请告诉我.

                  谢谢.

                  解决方案

                  这可能是由 Firebase Cloud Messaging 中的不切实际的心跳间隔引起的.

                  FCM 的工作原理是维持从 Android 设备到 Google 服务器的空闲套接字连接.这很棒,因为它几乎不消耗电池电量(与轮询相反),并且它允许在消息到达时立即唤醒设备.

                  为确保连接保持活动状态,Android 将在移动连接上每 28 分钟发送一次检测信号,在 WiFi 上每 15 分钟发送一次检测信号.如果心跳失败,则连接已终止,FCM 将重新建立它并尝试检索任何未决的推送通知.心跳间隔越高,消耗的电池越少,设备从睡眠中唤醒的次数就越少.

                  但是,这是有代价的:心跳间隔越长,识别断开的套接字连接所需的时间就越长.在部署 FCM 之前,Google 尚未在现实生活中对这些间隔进行足够彻底的测试.这些间隔的问题是由网络路由器和移动运营商造成的,它们会在几分钟不活动后断开空闲套接字连接.

                  更多信息可以在我的博客上找到:

                  http://eladnava.com/google-cloud-messaging-extremely-unreliable/

                  作为一种解决方法,请考虑 Pushy (https://pushy.me),它是 GCM 的直接替代品/FCM 大大提高了通知速度和可靠性(完全披露 - 我创立了 Pushy).

                  In Test app, I have implemented FCM for sending notification messages using

                  https://github.com/firebase/quickstart-android/tree/master/messaging

                  For testing I sent the message(8:42 PM) from firebase console using the "New Message" under Notification.

                  But in my emulator, I have received the message at 9:06 PM

                  Please let me know if there is anything to do reduce the delay.

                  Thank you.

                  解决方案

                  This could be caused by the unrealistic heartbeat intervals in Firebase Cloud Messaging.

                  FCM works by maintaining an idle socket connection from an Android device to Google’s servers. This is great because it barely consumes battery power (contrary to polling), and it allows the device to be woken up instantly when a message arrives.

                  To make sure that the connection remains active, Android will send a heartbeat every 28 minutes on mobile connection and every 15 minutes on WiFi. If the heartbeat failed, the connection has been terminated, and FCM will re-establish it and attempt to retrieve any pending push notifications. The higher the heartbeat interval, the less battery consumed and the less times the device has to be woken up from sleep.

                  However, this comes at a great price: the longer the heartbeat interval, the longer it takes to identify a broken socket connection. Google has not tested these intervals in real-life situations thoroughly enough before deploying FCM. The problem with these intervals is caused by network routers and mobile carriers, who disconnect idle socket connections after a few minutes of inactivity.

                  More info is available on my blog:

                  http://eladnava.com/google-cloud-messaging-extremely-unreliable/

                  As a workaround, please consider Pushy (https://pushy.me), a drop-in replacement for GCM/FCM which greatly improves notification speed & reliability (Full disclosure - I founded Pushy).

                  这篇关于Android:FCM中接收消息的延迟(onMessageReceived)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Firebase 云消息的可靠性如何? 下一篇:使用 Firebase 通知作为通知图标的灰色方块

                  相关文章

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

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

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