android - flutter 的firebase推送通知图标

标签 android flutter push-notification icons flutter-notification

我制作了一个应用程序并实现了推送通知,它可以工作,但我尝试使用 image.png 更改默认图标,但它没有按我预期的方式工作。这是我的通知的外观:enter image description here

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

enter image description here

我在我的 android manifest 中添加了这个:

<!-- 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" />

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

最佳答案

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

对于您的确切范围,您需要位于特定位置的 drawable-size 文件夹,其中包含名为 ic_notifications 的 pngs。我建议你用这个amazing tool生成具有正确布局的所有必需图标(透明上的白色)。

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

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#FFFFFF</color>
</resources>

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

关于android - flutter 的firebase推送通知图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64304512/

相关文章:

android - android中的缓存 Activity

android - Swarm App Android - 操作栏

flutter - 如何在 Flutter 小部件测试中点击列表或网格的所有项目?

swift - FIRInstanceID.instanceID().token() 和 Messaging.messaging().fcmToken 有什么区别?

android - 如何从 Web 服务动态更新 Android 中的 Assets 文件夹?

android - 无论如何在Android中自动接听来电?

flutter - ClojureDart : Execution error at cljd. 编译器/load-libs-info (compiler.cljc :126). EOF 读取时

flutter - 如何在 Flutter 中创建带有图像的单选按钮

ios - 收到推送消息后,如何更新 iOS 主屏幕中的通知角标(Badge)编号?

iphone - 推送通知 - 捕捉它们?