C# – Push Notifications icon displaying gray color

androidcfirebasexamarinxamarin.android

In my app Firebase push notification not displaying icon properly, It showing total gray color icon in notification.
Code I using for implementing notifications

var notificationBuilder = new Notification.Builder(this)
.SetSmallIcon(Resource.Drawable.ic_launcherLmg)
.SetContentTitle(user.Organization)
.SetSubText(user.ModuleName)
.SetContentText(user.BodyText)
.SetAutoCancel(true)
.SetContentIntent(pendingIntent)
.Build();

Icon I am setting at SetSmallIcon(Resource.Drawable.ic_launcherLmg) line.
ic_launcherLmg icon is available in below folders wtih given dimensoins

  1. drawable-idpi–36×36
  2. drawable-mdpi–48×48
  3. drawable-hdpi–72×72
  4. drawable-xhdpi–96×96

App targating Highest 8.1 API.
Minimun 5.0 API.

Screenshot of push notification

enter image description here

Best Answer

Maybe your icon is not showing with background fcm push? So you need to put this inside application tag inside manifest as described here here:

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

Android displays this custom default icon for all notification messages where the notification icon is not explicitly set.

Related Topic