flutter firebase 推送通知图标
flutter firebase push notification icon
我制作了一个应用程序并实现了推送通知,它可以正常工作,但我尝试使用 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" />
我不知道我做错了什么,但你能帮我吗?
meta-data
标签中的android:resource
(@folder
/name
)是指通知图标应该位于android\app\src\main\res\folder
-size
\name
.png.
对于您的确切范围,您需要特定位置的 drawable
-size
文件夹以及名为 ic_notifications
的 png。我建议您使用此 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>
额外: application
标签中的 android:icon
指的是应用程序的图标。只是想添加这条额外的信息,因为当找到的示例非常相似时,一开始可能会造成混淆。
我制作了一个应用程序并实现了推送通知,它可以正常工作,但我尝试使用 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" />
我不知道我做错了什么,但你能帮我吗?
meta-data
标签中的android:resource
(@folder
/name
)是指通知图标应该位于android\app\src\main\res\folder
-size
\name
.png.
对于您的确切范围,您需要特定位置的 drawable
-size
文件夹以及名为 ic_notifications
的 png。我建议您使用此 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>
额外: application
标签中的 android:icon
指的是应用程序的图标。只是想添加这条额外的信息,因为当找到的示例非常相似时,一开始可能会造成混淆。