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

      <tfoot id='OXrEL'></tfoot>

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

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

        FCM 默认图标使用无效渐变

        时间:2023-07-30

        • <legend id='F2TWh'><style id='F2TWh'><dir id='F2TWh'><q id='F2TWh'></q></dir></style></legend>
            <tbody id='F2TWh'></tbody>

            <tfoot id='F2TWh'></tfoot>
            1. <small id='F2TWh'></small><noframes id='F2TWh'>

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

                  本文介绍了FCM 默认图标使用无效渐变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  未使用 Android 清单的默认 FCM 图标.而是使用 Android 标准图标.在 logcat 中它说:

                  The default FCM icon of the Android manifest is not used. Instead the Android standart icon is used. In the logcat it says:

                  E/FirebaseMessaging:ID 为 2131230849 的图标使用了无效的渐变.使用后备图标.

                  E/FirebaseMessaging: Icon with id: 2131230849 uses an invalid gradient. Using fallback icon.

                  默认图标只包含一种颜色.我使用多个不同的图标对其进行了测试,但始终使用 Android 标准图标.

                  The default icon only contains one color. I tested it with multiple different icons but always the Android standart icon is used.

                  推荐答案

                  更新:firebase 在 12.0.0 版中已修复

                  UPDATE: fixed by firebase in version 12.0.0

                  下面的错误代码已经更新,它在 8.0 上运行良好,同时防止了我原始答案中概述的错误.

                  The faulty code below has been updated with this and it works great on 8.0, while preventing the bug outlined in my original answer.

                  @TargetApi(26)
                  private final boolean zza(int var1) {
                      if(VERSION.SDK_INT != 26) {
                          return true;
                      } else {
                          try {
                              if(this.zzb.getResources().getDrawable(var1, (Theme)null) instanceof AdaptiveIconDrawable) {
                                  Log.e("FirebaseMessaging", (new StringBuilder(77)).append("Adaptive icons cannot be used in notifications. Ignoring icon id: ").append(var1).toString());
                                  return false;
                              } else {
                                  return true;
                              }
                          } catch (NotFoundException var2) {
                              return false;
                          }
                      }
                  }
                  

                  <小时>

                  这并不能解决问题,但从评论中我被要求将其作为答案.这是来自 firebase 11.8.0 的代码,它是罪魁祸首,并且仅在 Android 8.0 (API 26) 上.进行此检查的原因是因为存在带有自适应图标的 Android 8.0 通知错误 https://www.bleepingcomputer.com/news/mobile/android-oreo-adaptive-icons-bug-sends-thousands-of-phone-into-infinite-boot-loops/ 所以这段代码可以防止这种情况发生,但这样做也可以防止非自适应图标正确显示


                  This doesnt solve the issue, but from the comments I was asked to put it as an answer. Here is the code from firebase 11.8.0 that is the culprit and only on Android 8.0 (API 26). The reason for this check is because there is an Android 8.0 notification bug with adaptive icons https://www.bleepingcomputer.com/news/mobile/android-oreo-adaptive-icons-bug-sends-thousands-of-phones-into-infinite-boot-loops/ so this code prevents that, but in doing so, also prevents non-adaptive icons from showing up properly

                      @TargetApi(26)
                  private final boolean zzid(int var1) {
                      if(VERSION.SDK_INT != 26) {
                          return true;
                      } else {
                          try {
                              Drawable var2;
                              if((var2 = this.mContext.getResources().getDrawable(var1, (Theme)null)).getBounds().height() != 0 && var2.getBounds().width() != 0) {
                                  return true;
                              } else {
                                  Log.e("FirebaseMessaging", (new StringBuilder(72)).append("Icon with id: ").append(var1).append(" uses an invalid gradient. Using fallback icon.").toString());
                                  return false;
                              }
                          } catch (NotFoundException var3) {
                              return false;
                          }
                      }
                  }
                  

                  我在我的 logcat 中注意到,我的应用程序每次通知都会点击此代码两次,它会尝试根据 Firebase 的说明在清单中设置我的可绘制通知,然后再次点击它以尝试为启动器图标执行此操作.两者都失败了,即使我让它们成为纯色可绘制对象.

                  I've noticed in my logcat, that my app hits this code twice per notification, it tries for my notification drawable which i set in the manifest as per Firebase's instructions, then hits it again trying to do it for the launcher icon. Both fail, even when I make them solid color drawables.

                  根据 southrop 的另一条评论,firebase 团队已意识到该问题并正在努力修复,但没有给出时间表.

                  As per another comment from southrop, the firebase team is aware of the issue and working on a fix but no timeline given.

                  此代码不在 11.6.0 及更低版本中,因此如果您暂时确实需要此代码,请降级您的 Firebase.

                  This code is not in 11.6.0 and lower, so if you really need this working for the time being, downgrade your firebase.

                  希望这可以帮助其他找到此帖子搜索错误的人

                  Hope this helps others who find this post searching for the error

                  这篇关于FCM 默认图标使用无效渐变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:GCM(现在的 FCM)是否有任何限制? 下一篇:如何处理 FirebaseInstanceId.getInstance().getToken() = null

                  相关文章

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

                    <tfoot id='vsju6'></tfoot>

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

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

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