[英]Android 9+ device misses icon on application in heads-up notification
TL;DR :Firebase 雲消息僅在 Android 9+ 設備的“抬頭”通知中不顯示我的應用程序圖標。 https://developer.android.com/guide/topics/ui/notifiers/notifications#Heads-up
更長的版本:
當我直接從 Firebase 或任何 Rest 客戶端將雲消息發送到https://fcm.googleapis.com/fcm/send發出聲音,它會在一段時間內消失,但會留在通知欄和通知抽屜中。
在消息傳遞到在 Android 10 或 9(但不是全部)上運行的設備之前,一切正常。 通知欄和通知抽屜工作正常,消息本身看起來與舊 Android 版本完全相同。 但是提示錯過了我的應用程序的圖標。 到目前為止,我還沒有向 Firebase 發送任何帶有有效負載的“圖標”,但即使我將帶有 URL 的“圖標”屬性設置為我的圖標,它仍然不會出現在提示中。 我已將相同的 URL 放在“圖像”屬性中,然后圖像出現在提示中,但我相信它不是應該用於在通知中顯示應用程序圖標的屬性。
有沒有人注意到同樣的問題? 我嘗試查看 Google Android 文檔 - 但它看起來已經過時並以 Android 8 結尾。我嘗試了 Firebase 文檔,但它說“未附加圖標”屬性是可選的。
我在以下位置測試了通知:
有效載荷只是:
{
"to": "(...)",
"notification": {
"title": "Push from RestClient",
"body": "Notification body"
},
"data": {}
}
當然,我已經為 default_notification_icon、顏色和通道添加了 Firebase 所需的。 這不是這里的解決方案。
您需要在清單中添加 FCM 元數據。xml
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_logo_white" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/app_theme_blue" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.