Notification Icon not correct

Gordon S 501 Reputation points
2021-06-29T08:26:00.997+00:00

I am creating a notification which is displaying OK on iOS but it isn't fully correct on Android.

The following code creates the notification, when the app is in the foreground:

            int NOTIFICATION_ID = 1000;
            var channelId = FirebasePushNotificationManager.DefaultNotificationChannelId;
            var msgTitle = e.Data["title"].ToString(); // "title";
            var msgContent = e.Data["body"].ToString(); // "message content";

            // Build the notification:
            var builder = new NotificationCompat.Builder(this, channelId)
                          .SetAutoCancel(true) // Dismiss the notification from the notification area when the user clicks on it
                          .SetContentTitle(msgTitle) // Set the title
                          .SetSmallIcon(Resource.Drawable.k_notification_icon) // This is the icon to display
                          .SetContentText(msgContent); // the message to display.

            builder.SetLargeIcon(Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.k_notification_icon));

            // Publish the notification:
            var notificationManager = NotificationManagerCompat.From(this);
            notificationManager.Notify(NOTIFICATION_ID, builder.Build());

The issues are:

When the notification "popup" appears, the title and content are there but the image is not.

When viewing the notification by pulling down / revealing the notifications, the image is there but the colour is wrong. It is kind of purple rather than red. However, if the app is in the background when the notification arrives, the icon is the correct colour (the icon still doesn't appear in the "popup" message)

I am using the CrossGeeks FirebasePushNotificationPlugin.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
{count} votes