Firebase 通知图标为灰色

问题描述 投票:0回答:5

虽然我在stackoverflow中做了这个解决方案,但图标仍然是一样的。

    <meta-data   android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_launcher" />

此处顶部图标:

当我滑动顶部栏时,我看到了这个:

问题出在哪里? 我还使用此网站创建透明图标:https://jgilfelt.github.io/AndroidAssetStudio/icons-notification.html#source.space.trim=1&source.space.pad=0&name=ic_stat_ic_launcher

我的 res 文件现在也是这样(来自上面链接的可绘制文件夹):

此处的图标:

firebase flutter firebase-realtime-database push-notification firebase-cloud-messaging
5个回答
10
投票

就我而言,问题是我放置了

<meta-data android:name="com.google.firebase.messaging.default_notification_icon" … />

AndroidManifest.xml 中主

<activity/>

 标签下的 
标签

显然,它应该位于

<application/>
标签下(层次结构中较高的位置)。


4
投票

用于通知的图标必须是白色且背景透明,否则会显示灰色框。

您可以查看这篇文章以了解更多信息。

我遇到了同样的问题,并通过更改图标图像解决了它。

这是一个示例图像:


1
投票

我下载了这个包,它自动生成启动器图标,它工作得很好

https://pub.dev/packages/flutter_launcher_icons


0
投票

您是否尝试将清单行更改为:

<meta-data   android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_ic_launcher" />

从您的屏幕截图看来,您只有不同分辨率的 ic_stat_ic_launcher 文件。

如果您想使用mipmap/ic_launcher文件,您需要将不同大小的文件添加到其他mipmap文件夹中(就像您拥有mipmap/launcher_icon.png文件一样),否则可能找不到使用哪个文件


0
投票

对于那些无法理解通知图标要求的人,让我来分解一下。

让我们考虑一下通知图标 facebook,它是白色的“f”,背景是蓝色圆圈。现在,对于通知图标,使图标中的“f”透明,并在 android studio 中使用

asset manager
生成通知图标。您会注意到蓝色背景是透明的,“f”是白色的,现在其余的位置与可绘制生成的文件夹在相应的文件夹中的位置相同。

<meta-data   
   android:name="com.google.firebase.messaging.default_notification_icon"
   android:resource="@drawable/app_icon" />

<meta-data   
   android:name="com.google.firebase.messaging.default_notification_color"
   android:resource="@color/facebook_blue_color" />

就是这样。

© www.soinside.com 2019 - 2024. All rights reserved.