简体   繁体   English

如何在Android 8.0.0上获得正确显示的通知图标?

[英]How do I get a notification icon to show up correctly on Android 8.0.0?

I'm working on an app and setting up push notifications. 我正在开发一个应用程序并设置推送通知。 Things are working as expected with my notification icon on most devices (including 7.1.1 and 8.1.0 simulator devices). 在大多数设备(包括7.1.1和8.1.0模拟器设备)上,我的通知图标正常运行。 However, on 8.0.0 devices shows a circular solid-color dot instead of the icon when the notification tray is open and a teal-and-white android robot head in the notification strip when the tray is closed (and on other phones a solid dot in the strip instead of the android robot). 但是,在通知托盘打开时,8.0.0设备显示圆形纯色点而不是图标,当托盘关闭时,通知条中有一个蓝绿色的机器人机器人头(在其他手机上是固体在条带中的点而不是android机器人)。

AndroidManifest.xml: AndroidManifest.xml中:

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

I started with my icon in mipmap , but copied them over to drawable and tried that too - but that had no effect. 我开始在mipmap使用我的图标,但是将它们复制到drawable并尝试了 - 但这没有任何效果。

Per this I opened and re-saved all my pngs with a background color - but that had no effect. 按此,我打开并重新保存了所有背景颜色的png - 但这没有任何效果。

I've tried fiddling with the notifColor and I can get the color of the dot to change, but it is still just a solid-color dot. 我试着摆弄notifColor ,我可以改变点的颜色,但它仍然只是一个纯色点。

I don't think it matters for this, but I'm using react-native and react-native-fcm. 我认为这不重要,但我正在使用react-native和react-native-fcm。 My compile-sdk and build tools versions are both 26. If the firebase version matters, this is what I have in my app/build.gradle : 我的compile-sdk和build工具版本都是26.如果firebase版本很重要,这就是我在app/build.gradle

compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'

How can I get the notification icon to show up correctly in Android 8.0.0? 如何在Android 8.0.0中正确显示通知图标?

Update 更新

comparison screenshots of Android 8.0.0 (left) and Android 7.1.1 (right, expected). Android 8.0.0(左)和Android 7.1.1(右,预期)的比较截图。

任务栏/通知条的预期与实际值

通知抽屉打开时的预期与实际通知

I also tried throwing in the icon setting when sending the notifications. 我也尝试在发送通知时投入图标设置。 It changes the icon to what I set it to on Android 7.1.1/8.1.0, but sticks with the solid-dot on 8.0.0. 它将图标更改为我在Android 7.1.1 / 8.1.0上设置的图标,但坚持使用8.0.0上的实心点。

You need to make a custom icon for notification, depending on device/os as you said you'll see only a square white shape. 您需要为通知创建一个自定义图标,具体取决于您所说的设备/操作系统,您只会看到方形白色形状。 So make a custom icon with transparency and solid color that match your brand requirement. 因此,制作一个具有透明度和纯色的自定义图标,以满足您的品牌要求。

Try removing the below line, worked for me 尝试删除以下行,为我工作

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 android通知栏(图标)显示不正确 - android notification bar (icon) show not correctly Android-如何使操作栏上的“向上图标”按下的颜色通过png显示? - Android - How do I make the actionbar “up icon” pressed color show through the png? 如何在Android的通知文本区域中显示图标 - How to show icon in the notification text Area in android 如何显示android通知和应用程序图标 - how to show android notification and application icon 如何让图标显示在 Android Material Buttons 中的文本旁边? - How to get an icon to show up next to text in Android Material Buttons? 如何在运行时设置android通知图标? - How do I set android notification icon at runtime? 如何在android studio中显示通知图标 - How to show a notification icon in android studio 如何在状态栏中显示图标而不在通知抽屉中显示通知? - How do I show an Icon in the status bar without showing a Notification in the notification drawer? 如何获取ActionBarCompat以显示普通的默认图标(在清单中的application / intent-filter android:icon属性中设置)? - How do I get ActionBarCompat to show the normal default icon (set in the application/intent-filter android:icon attribute in the manifest)? 如何在Android上将向上操作图标更改为带有文本的按钮? - How do I change the up action icon into button with text on Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM