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

      • <bdo id='TUkEs'></bdo><ul id='TUkEs'></ul>
      <tfoot id='TUkEs'></tfoot>

      <legend id='TUkEs'><style id='TUkEs'><dir id='TUkEs'><q id='TUkEs'></q></dir></style></legend>
    1. <small id='TUkEs'></small><noframes id='TUkEs'>

        FirebaseMessagingService 默认在后台运行吗?

        时间:2023-07-30

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

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

                    <tbody id='DL3eX'></tbody>
                  本文介绍了FirebaseMessagingService 默认在后台运行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  FirebaseMessagingService 是否像 IntentService 一样在后台运行?

                  Does the FirebaseMessagingService run in the background similar to how an IntentService operates?

                  我看到 FirebaseMessagingService 范围 Service 不在后台运行,但我想确定我是否应该在FirebaseMessagingService 异步或同步.

                  I see that FirebaseMessagingService extents Service which does not run in the background, but I'd like to be sure whether or not I should be doing any work inside the FirebaseMessagingService asynchronously or synchronously.

                  谢谢

                  回答:

                  FirebaseMessagingService 的方法 onMessageReceived(RemoteMessage message) NOT 在主线程上调用 - 所以所有工作都应该同步进行.

                  FirebaseMessagingService's method onMessageReceived(RemoteMessage message) is NOT called on the main thread - so all work should be synchronously.

                  推荐答案

                  FirebaseMessagingService 的方法 onMessageReceived(RemoteMessage message) 被在后台"调用(不在UI/主线程).如果您尝试在 onMessageReceived(RemoteMessage message) 中进行异步工作,您将收到一条错误消息:

                  FirebaseMessagingService's method onMessageReceived(RemoteMessage message) is called "in the background" (not on the UI/Main thread). If you try do asynchronous work inside onMessageReceived(RemoteMessage message) you will receive an error saying:

                  方法execute必须从主线程调用,当前推断线程为worker.

                  Method execute must be called from the main thread, currently inferred thread is worker.

                  所以在 onMessageReceived(RemoteMessage message) 内完成的所有工作都应该同步完成,因为它在自己的后台工作线程中.

                  So all work that is done within onMessageReceived(RemoteMessage message) should be done synchronously because it's in its own background worker thread.

                  这篇关于FirebaseMessagingService 默认在后台运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:firebase-messaging:9.4.0 错过了 GoogleApiAvailability 下一篇:Firebase 云消息传递无法解析主题名称

                  相关文章

                  • <bdo id='8l92D'></bdo><ul id='8l92D'></ul>
                  <legend id='8l92D'><style id='8l92D'><dir id='8l92D'><q id='8l92D'></q></dir></style></legend>

                  1. <small id='8l92D'></small><noframes id='8l92D'>

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

                    2. <tfoot id='8l92D'></tfoot>