簡體   English   中英

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文件夾,其中 png 名為ic_notifications 我建議你使用這個神奇的工具來生成所有需要的具有正確布局的圖標(透明上的白色)。

因為您的通知也有顏色,所以您必須在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指的是應用程序的圖標。 只想添加這條額外的信息,因為當找到的示例非常相似時,一開始可能會令人困惑。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM