简体   繁体   中英

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). 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).

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.

Per this I opened and re-saved all my pngs with a background color - but that had no effect.

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.

I don't think it matters for this, but I'm using react-native and 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 '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?

Update

comparison screenshots of Android 8.0.0 (left) and Android 7.1.1 (right, expected).

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

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM