[英]Android: Firebase push notification different icon while app is on foreground and another while app is on background
Yes.是的。 This does happen.
这确实发生了。 It can be fixed by setting color to the icon,when the notification is generated from inside the app.
当从应用程序内部生成通知时,可以通过为图标设置颜色来修复它。
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)))
To keep it consistent, even for the notification generated in the background, a line can be written in the manifest:为了保持一致,即使是在后台生成的通知,也可以在清单中写一行:
<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.