zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.77k stars 2.05k forks source link

Android app notification icon showing background white #1326

Open anuj-njoshi opened 4 years ago

anuj-njoshi commented 4 years ago

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

yehiaemad commented 4 years ago

any updates how to solve this

Dallas62 commented 4 years ago

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
artyorsh commented 4 years ago

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

Dallas62 commented 4 years ago

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 😃

artyorsh commented 4 years ago

Do you mean this whole tag is not required anymore?

Dallas62 commented 4 years ago

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.

yehiaemad commented 4 years ago

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.

RRGT19 commented 4 years ago

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.

yehiaemad commented 4 years ago

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

TommyLeong commented 4 years ago

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

umagloire99 commented 3 years ago

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

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

CptMaumau commented 3 years ago

I used this method found on a SO thread with a white version of my logo. Then the color that you set will apply in the notification center.

scoutNinjaswapnil commented 10 months ago

I am also able to set the icon properly but not able to pass the color, can someone guide me what is the next step after generating and and pasting icon in respective folders

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