small icon on push notification not showing on android?

4.7k Views Asked by At

I have added small icon in push notification but still not showing. I am using android 10 emulator. My icon have fulfill requirement that using white color with no background and store in mipmap folder. I have tried some solution on previous same question on stackoverflow but still not working. this is my code

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                context, CHANNEL_ID)
                .setSmallIcon(R.mipmap.ic_notification)
                .setContentTitle(contentTitle)
                .setContentText(contentText)
                .setContentIntent(pendingIntent)
                .setPriority(NotificationCompat.PRIORITY_DEFAULT)
                .setAutoCancel(true);

Push notification icon still showing like this enter image description here

I have tried add this code on android manifest but still not working too

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

my targetSDK is 29

Did you ever encounter same issues and solved ?

1

There are 1 best solutions below

2
Abdul Haseeb On

Action Bar Icons require a file size of 24×24 pixels at the baseline size (MDPI). However, the image itself must be no more than 22×22 pixels centered within the Icon file.

The Icon Design must be single color white, #ffffff.

MDPI - 24 x 24  (drawable-mdpi)
HDPI - 36 x 36  (drawable-hdpi)
XHDPI - 48 x 48  (drawable-xhdpi)
XXHDPI - 72 x 72  (drawable-xxhdpi)
XXXHDPI - 96 x 96  (drawable-xxxhdpi)

For more details look Android Cheatsheet and Official Android documentation.