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

时间:2018-03-08 23:08:31

标签: android push-notification firebase-cloud-messaging android-8.0-oreo

我正在开发应用并设置推送通知。在大多数设备(包括7.1.1和8.1.0模拟器设备)上,我的通知图标正常运行。但是,在通知托盘打开时,8.0.0设备显示圆形纯色点而不是图标,当托盘关闭时,通知条中有一个蓝绿色的机器人机器人头(在其他手机上是固体在条带中的点而不是android机器人)。

的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"/>

我在mipmap开始使用我的图标,但将其复制到drawable并尝试了 - 但这没有效果。

Per this我打开并重新保存了所有背景颜色的png - 但这没有效果。

我试过摆弄notifColor并且我可以改变点的颜色,但它仍然只是一个纯色点。

我认为这不重要,但我正在使用react-native和react-native-fcm。我的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'

如何在Android 8.0.0中正确显示通知图标?

更新

Android 8.0.0(左)和Android 7.1.1(右,预期)的比较截图。

expected vs actual of the taskbar / notification strip

expected vs actual of the notification while the notification drawer is open

我还尝试在发送通知时投入图标设置。它将图标更改为我在Android 7.1.1 / 8.1.0上设置的图标,但坚持使用8.0.0上的实心点。

2 个答案:

答案 0 :(得分:0)

您需要制作一个自定义通知图标,具体取决于您所说的设备/操作系统,您只能看到方形白色形状。因此,制作一个具有透明度和纯色的自定义图标,以满足您的品牌要求。

答案 1 :(得分:0)

尝试删除以下行,为我工作

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