3

My Android app uses Firebase Cloud Messaging for notifications. When notifications come in, the icon isn't turned white like the other icons.

enter image description here

I'm using targetSdkVersion 23.

I have this in my manifest:

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

With a PNG file at android/app/src/main/res/drawable/notification_icon.png.

How can I get the icon to behave normally?

Flavien
  • 7,497
  • 10
  • 45
  • 52

6 Answers6

1

Take a look at the icon in the SVG designer. Have you assigned a colour to it or is it showing white there?

Will Jones
  • 1,861
  • 13
  • 24
  • It's a color image, but even if I turn it white, it's not the same shade of white as the other ones, and it doesn't invert on a white background (so it is completely invisible on a white background) – Flavien Jun 05 '18 at 16:30
  • Try converting it to an SVG, I can't say I've ever used PNGs for these icons. – Will Jones Jun 05 '18 at 16:45
1

As suggested by Will Jones, the solution was to use a SVG file and convert it to XML using this: http://inloop.github.io/svg2android/. I then copied the file to android/app/src/main/res/drawable/notification_icon.xml and deleted the old PNG file.

The icon now renders properly.

Flavien
  • 7,497
  • 10
  • 45
  • 52
0

Try this.

then set your resource to white: android:resource="@color/google_white"

Red M
  • 2,609
  • 3
  • 30
  • 50
0

One option is to use the Notification icon generator

Arthur Thompson
  • 9,087
  • 4
  • 29
  • 33
0

I'm a bit late but try to add this to your manifest

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/notification_icon_color" />
Mang Jose
  • 3
  • 2
0

In my case I have an ionic project, so the answer of @Flavien is correct but instead of:

android/app/src/main/res/drawable/notification_icon.xml

You need to write without the .xml suffix, like this:

android/app/src/main/res/drawable/notification_icon
RafaelJan
  • 3,118
  • 1
  • 28
  • 46