flutter firebase 推送通知图标

Lui*_*aru 3 icons android push-notification flutter flutter-notification

我制作了一个应用程序,并实现了推送通知,它可以工作,但我尝试使用 a 更改默认图标image.png,但它没有按我预期的方式工作。这是我的通知的样子:在此输入图像描述

我希望我的图标看起来像这样:

在此输入图像描述

我在我的 Android 清单中添加了以下内容:

<!-- Add custom icon to the notifications -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notifications" />
<!-- Change the color of the icon -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorPrimary" />
Run Code Online (Sandbox Code Playgroud)

我不知道我做错了什么,但你能帮助我吗?

Und*_*ore 7

标签中的android:resource(@ folder/ name)meta-data表示通知图标应位于 android\app\src\main\res\ folder- size\ name.png 中。

对于您的确切范围,您需要特定位置的drawable-文件夹,其中包含名为 的 png 。我建议您使用这个神奇的工具来生成具有正确布局的所有所需图标(透明白色)。sizeic_notifications

因为您的通知也有颜色,所以您必须添加其中colors.xmlandroid/app/src/main/res/values包含您的colorPrimary

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#FFFFFF</color>
</resources>
Run Code Online (Sandbox Code Playgroud)

额外:标签android:icon中的application指的是应用程序的图标。只是想添加这条额外的信息,因为当发现的示例非常相似时,一开始可能会令人困惑。