React-native-push-notification: Android app notification icon showing background white

Created on 28 Feb 2020  路  11Comments  路  Source: zo0r/react-native-push-notification

Using above android 9.0 > version
Notification icon converted to transparent
Still showing white icon background.

Most helpful comment

According to documents.
You need to:

Create an asset that only uses white pixels, on a transparent background. It's important to not use any color other than white.

Your asset must be called ic_notification.png
Your assets must be placed inside mipmap-* directories and not drawable-* (as @wuppious mentioned).

Your asset dimensions (in pixels):
mipmap-mdpi - 24x24
mipmap-hdpi- 36x36
mipmap-xhdpi- 48x48
mipmap-xxhdpi- 72x72
mipmap-xxxhdpi- 96x96

Then you can pass color: 'what you need' for icon in notification object.

All 11 comments

any updates how to solve this

Hi
Did you try to change the parameter of:

        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                    android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->

Like:

@android:color/transparent

@Dallas62 transparent doesn't seem to work on Android 10 (Pixel 3 on screenshot)
However, it there is no issue for Android 8

image

I would like to figure out how to get rid of this, but, unfortunately, you should rebuild Android app whenever manifest is changed, so it makes it quite long to test. Btw, why resource is stricted to be a color? It's not stricted by the system afaik, so you should be able to use any type of resource, e.g mipmap icons.

Hi @artyorsh
I took a look at the library code, it seems you can remove :

        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                    android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->

The color property should not be set this way.
Actually the library force the resource to be color, if you have a bit of time to test with mipmaps, this could be great 馃槂

Do you mean this whole tag is not required anymore?

getNotificationColor
use of getNotificationColor

If you don't set it on the manifest, this will use the default Android value, I hope this is will resolve the issue. No exception will be throw in the app, it will ignore the color, expect if it's set in the notification.

According to documents.
You need to:

Create an asset that only uses white pixels, on a transparent background. It's important to not use any color other than white.

Your asset must be called ic_notification.png
Your assets must be placed inside mipmap-* directories and not drawable-* (as @wuppious mentioned).

Your asset dimensions (in pixels):
mipmap-mdpi - 24x24
mipmap-hdpi- 36x36
mipmap-xhdpi- 48x48
mipmap-xxhdpi- 72x72
mipmap-xxxhdpi- 96x96

Then you can pass color: 'what you need' for icon in notification object.

According to documents.
You need to:

Create an asset that only uses white pixels, on a transparent background. It's important to not use any color other than white.

Your asset must be called ic_notification.png
Your assets must be placed inside mipmap-* directories and not drawable-* (as @wuppious mentioned).

Your asset dimensions (in pixels):
mipmap-mdpi - 24x24
mipmap-hdpi- 36x36
mipmap-xhdpi- 48x48
mipmap-xxhdpi- 72x72
mipmap-xxxhdpi- 96x96

It's working. The icon has a white or transparent background color by default.
There is a way to assign a custom background color to the ic_notification.png? or we need to specify it somewhere else?
The idea is to show the ic_notification with the color of our branding, and not just white/transparent.

@RRGT19 Try passing color: ' what you need' in notification object.

Hello @RRGT19 ... I actually add in new notification icon under the mipmap-folders and named ic_notification.png
I'm still getting a white icon when receiving notification.

One thing I realized is, when adding my image to https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=image&source.space.trim=1&source.space.pad=0&name=ic_stat_ic_launcher it returns me a blank white image as well. Not sure if this is an image issue or what.

Update 1.0

I think my issue is because of .. not providing a image which is ONLY IN WHITE. My logo is having some colors, will test and re-update here. Read more here

Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray

@RRGT19 Try passing color: ' what you need' in notification object.

Please i have the same the issue how to pass the color?

Was this page helpful?
0 / 5 - 0 ratings