简体   繁体   English

Android:Firebase 应用程序在前台时推送通知不同的图标,而当应用程序在后台时,另一个图标

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

How can I show same icon while app is on background or foreground?当应用程序在后台或前台时,如何显示相同的图标? Below I have attached my screenshot下面我附上了我的截图

应用通知截图

I have used this app icon for my notification我已将此应用程序图标用于我的通知

通知图标

Thanks in advance!提前致谢!

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.

相关问题 应用程序在前台时收到的推送通知与应用程序在后台时收到的推送通知不同 - Push notification received while the app is in the foreground is different from push notification received when the app is in background 当应用程序处于前台状态时,Firebase消息在收到推送通知后停止 - Firebase messaging stops after receiving a push notification while app in foreground 当应用程序在前台时发送Firebase推送通知时,应用程序崩溃(仅在棉花糖(6.0.1)上),但在后台运行时工作正常 - app crashes (only on Marshmallow(6.0.1)) when i send firebase push notification while app is on foreground but works fine when in background 在Android应用处于前台模式时获取推送通知,但在应用未运行或处于空闲模式时无法获取通知 - Getting push notification while Android app is in foreground mode but unable to get notification while app is not running or idle mode 带有来自服务器(php)的图像的 Android Firebase 推送通知未在通知中显示图像,而应用程序在后台 - Android Firebase Push Notification with image from server(php) not showing image in notification while app in background 当通过fireBase收到推送通知时,IONIC2在android后台应用程序时增加徽章 - IONIC2 Increment badges while app in background on android when push notification is received via fireBase 我的应用未运行时,如何发送类似Facebook的推送通知(背景/前景) - how can i send push notification like facebook while my app is not running(background/foreground) 当应用程序不在前台时,如何使用Firebase Cloud Messaging(Notification)在Android中获取抬头通知? - How to get Heads Up notification in android using Firebase Cloud Messaging(Notification) while the app is not in foreground? 在Android中-当应用程序处于前台时如何防止Firebase推送通知? - In android - How to prevent Firebase push notification when app is in foreground? 应用处于活动状态时,带有Firebase的推送通知不起作用 - Push Notification with Firebase not working while app is active
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM