'Flutter: Notification icon showing white circle
I have tried everything including changes in manifest file as well as putting the icon property in notification function but the notification icon is still white circle! My icons color is white with transparent background which is generated using https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=clipart&source.clipart=ac_unit&source.space.trim=1&source.space.pad=0&name=ic_stat_ac_unit.
My manifest file looks like this:enter image description here
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/notification_icon" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorPrimary" />
I have included the picture of my folder structure! What exactly am I missing?enter image description here
Solution 1:[1]
Instead of a .png image in the res folder, try to download,unzip and paste all the drawable folders in the res folder. ie, drawable, drawable-hdpi etc.
If you want to change the color of the icon,add the metadata tag after the notification icon tag
Go to "android\app\src\main\res\values" and add a colors.xml file Inside it add the color:
<color name="colorAccent">#00FF00</color>
I had also come across this issue and have shared my solution on Github as well. flutter_notification_icon_issue
Incase, this doesn't work for you, I would suggest creating a different icon in Android Asset Studio using the existing clipart that they have provided and try that once. Just to make sure that the icon that you have created is not the cause of the issue.
Solution 2:[2]
For those who arrive here lost, pay attention to the correct place where you must enter the meta-data
Solution 3:[3]
NotificationDetails(
android: AndroidNotificationDetails(
channel.id,
channel.name,
channelDescription: channel.description,
icon: '@mipmap/ic_notification_no_bg',
styleInformation: BigTextStyleInformation(''),
),
));
You need to provide a icon which does not have any background in AndroidNotificationDetails so App will pick this icon for Android version 11 for other versions it will pick default launcher Icon
Solution 4:[4]
For me answer given by @Marcos Silva worked. I also had correct icon, and was getting white circle in notification bar(for background notifications). When I moved meta tag right after application
tag, it started showing icon correctly.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user2549980 |
Solution 2 | Marcos Silva |
Solution 3 | Musab |
Solution 4 | samsonbek |