繁体   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