簡體   English   中英

Android:Firebase 應用程序在前台時推送通知不同的圖標,而當應用程序在后台時,另一個圖標

[英]Android: Firebase push notification different icon while app is on foreground and another while app is on background

當應用程序在后台或前台時,如何顯示相同的圖標? 下面我附上了我的截圖

應用通知截圖

我已將此應用程序圖標用於我的通知

通知圖標

提前致謝!

是的。 這確實發生了。 當從應用程序內部生成通知時,可以通過為圖標設置顏色來修復它。

 NotificationCompat.Builder(
 this,
 CHANNEL_ID
 )
.setSmallIcon(//your vector)
.setColor(ContextCompat.getColor(this, //color of the icon(mostly this may be 
the primary/secondary color that has been set ,according to the theme, in this 
case some hex of red)))

為了保持一致,即使是在后台生成的通知,也可以在清單中寫一行:

<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/(your vector)” />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/(color of the icon)” />

暫無
暫無

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

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