4

I am using Firebase Cloud Messaging with my Flutter app.

I am sending Push Notifications to my app using the Firebase Console.

My issue is regarding the notification icon on Android.

I have created an icon with Android Asset Studio, as follows:

enter image description here

Then I have included the downloaded assets into their respective folder at android/app/main/res/mipmap.

On Manifest I have included the needed meta-data code:

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

But when sending a notification, a white square is shown.

enter image description here

enter image description here

What am I missing or doing wrong?

Edit:

This my current file:

enter image description here

mvasco
  • 4,965
  • 7
  • 59
  • 120
  • Does this happen on every device or some devices? – Milan Tejani Sep 06 '21 at 11:53
  • Try putting them in `drawable` directories, not `mimpap` directories. AFAIK, `mimpap` is only for launcher icons. – CommonsWare Sep 06 '21 at 11:55
  • @CommonsWare, let me try your proposal – mvasco Sep 06 '21 at 12:15
  • Is the background actually transparent? Android will only use the outlines of your icon. – Alexander Hoffmann Sep 06 '21 at 12:24
  • Your image doesn't seems to be completely transparent , you need to make background transparent. – Nitish Sep 06 '21 at 12:55
  • @NitishChaudhary, I have created the image with a transparent background. How can I be sure that it is really transparent? – mvasco Sep 06 '21 at 12:59
  • What's the dimension of the image you are using , above attach image has a dimension of 512x512 which too large for notification. Can you reduce it to 24x24 , 36x36 and 48x48 for hdpi , xhdp and xxhdpi. – Nitish Sep 06 '21 at 13:10
  • To check transparency you can use online editor - https://www.photopea.com/ – Nitish Sep 06 '21 at 13:10
  • @NitishChaudhary, it is transparent now, but the issue is there. I have downloaded the assets from Android Asset Studio with their end size depending on their respective drawable folder – mvasco Sep 06 '21 at 13:22

3 Answers3

4

Background of notification icon should be transparent From Android 5.0 Lollipop Notification icons must be entirely white.

CHP
  • 192
  • 6
  • not necessary "must"... Android will exchange every not-fully-transparent pixel into solid white (or dk gray, depends on background color of status bar), only transparent ones will stay transparent – snachmsm Sep 06 '21 at 12:38
4

I think you generated the icons of wrong size. I re-generated them using the android asset studio and seems to be working at my end. You can download then using this link:

https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=text&source.text.text=capenergy&source.space.trim=1&source.space.pad=0&name=ic_stat_capenergy

Nitish
  • 3,075
  • 3
  • 13
  • 28
  • Thank you for your effort, I have downloaded your proposed link from Android Asset Studio, copied the respective drawable folders to res, and changed the AndroidManifest file including: – mvasco Sep 06 '21 at 13:50
  • But the same result with the notification icon – mvasco Sep 06 '21 at 13:51
  • 2
    Is your meta-data tag inside you application class tag? – Nitish Sep 06 '21 at 14:02
  • Use this link to confirm if image source has been added to correct places. [link](https://medium.com/nonstopio/change-the-firebase-notification-icon-in-a-flutter-245b7f7dc546) – Nitish Sep 06 '21 at 14:06
  • Yes, I have followed exactly the given tutorial – mvasco Sep 06 '21 at 14:07
  • 1
    i know you are in the right way. I will try later from the beginning.Thank you for your time and effort. – mvasco Sep 06 '21 at 14:15
2

I think you should checkout this. I also had a lot of problems with this so I saved that answer to my bookmarks ;)

Saddan
  • 1,546
  • 16
  • 19
Tarik Huber
  • 7,061
  • 2
  • 12
  • 18