Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Notification Always shows blank icon

I'm new with FCM. I cannot make FCM use my app icon as notification icon and the icon is always a white blank one.

I imported an icon to mipmap folders but nothing seems changed. As some dude say that this is because of lollipop notification as in this question

But the problem is, the FCM notification automatically pops up and I cannot get the Notification builder to override the icon. How can I change it?

like image 790
Mahdi Avatar asked Oct 03 '16 09:10

Mahdi


3 Answers

This is the default behaviour of FCM. When app is in background it will take white icon.

Use this tag and put it in your Manifest. For me this worked. Hope it works for you too. Ensure meta-data is inside application like the example mentioned in quickstart

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    tools:ignore="GoogleAppIndexingWarning">
    <!-- [START fcm_default_icon] -->
    <!-- Set custom default icon. This is used when no icon is set for incoming notification messages. -->
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/ic_stat_ic_notification" />
    <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
         notification message. -->
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorAccent" />
    <!-- [END fcm_default_icon] -->
    <!-- [START fcm_default_channel] -->
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_channel_id"
        android:value="@string/default_notification_channel_id" />
    <!-- [END fcm_default_channel] -->
    <activity
        android:name=".EntryChoiceActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".kotlin.MainActivity" />
    <activity android:name=".java.MainActivity" />
like image 114
Aniket Dhandhukia Avatar answered Oct 20 '22 02:10

Aniket Dhandhukia


If you are having this problem

enter image description here

See this link: Icon not displaying in notification: white square shown instead

I had the same problem. I solved by making transparent image from designer. Make sure your logo should be 72*72 pixels.

NOTE: Don't time waste in googling this issue, you just need a transparent icon which should be 72*72 dimensions.

like image 19
Däñish Shärmà Avatar answered Oct 20 '22 02:10

Däñish Shärmà


The only thing that worked for me was to generate a Notification icon image asset in Android studio. To use the an image as the notification icon, just set Asset type to "Image" and select the file.

Tip #1: use an icon which is of white color, on transparent background!

Tip #2: if the preview on the right side of the window contains only white squares, your notification icon will look just like that - white squares! enter image description here

Tip #3: the Name of the asset is what should be added into the meta-data tag in AndroidManifest

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

Source: Taken from this answer

like image 5
Aleksandar Avatar answered Oct 20 '22 01:10

Aleksandar