且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

带有新 Firebase 云消息系统的通知图标

更新时间:2023-02-27 08:34:40

很遗憾,这是 SDK 9.0.0-9.6.1 中 Firebase 通知的限制.当应用在后台时,启动器图标会从清单(带有必要的 Android 着色)用于从控制台发送的消息.

Unfortunately this was a limitation of Firebase Notifications in SDK 9.0.0-9.6.1. When the app is in the background the launcher icon is use from the manifest (with the requisite Android tinting) for messages sent from the console.

但是,使用 SDK 9.8.0,您可以覆盖默认值!在您的 AndroidManifest.xml 中,您可以设置以下字段来自定义图标和颜色:

With SDK 9.8.0 however, you can override the default! In your AndroidManifest.xml you can set the following fields to customise the icon and color:

<meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/notification_icon" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/google_blue" />

请注意,如果应用程序在前台(或发送数据消息),您可以完全使用自己的逻辑来自定义显示.如果从 HTTP/XMPP API 发送消息,您也可以始终自定义图标.

Note that if the app is in the foreground (or a data message is sent) you can completely use your own logic to customise the display. You can also always customise the icon if sending the message from the HTTP/XMPP APIs.