Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grey square as notification icon using Firebase notifications

Tags:

I am attempting to integrate Firebase Cloud Messaging into my android app. But when the app is in the background or closed, Firebase notification is displayed with grey square icon instead of my application's launcher icon.

How could I make the notification icon to be my application logo, without implementing Firebase server API and sending data messages?

like image 420
Sophia Avatar asked Aug 26 '16 01:08

Sophia


People also ask

What are notifications icons?

Android Status Bar icons are notifications in the graphical user interface (GUI) from apps running on your device. These notifications can contain text, graphics, and even controls.

What is a push notification icon?

Push notifications are automated notifications that the app sends mobile users if the push notification feature is enabled. When a push notification is sent, Android devices show a small push icon in the status bar and notification drawer.

What does FCM notification mean?

Firebase Cloud Messaging (FCM), formerly called Google Cloud Messaging (GCM), is a free cloud service from Google that allows app developers to send notifications and messages to users across a variety of platforms, including Android, iOS and web applications.


2 Answers

From Firebase 9.8.0 it is possible to change this icon, by adding info about this in Manifest:

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

Example you will find here:

https://github.com/firebase/quickstart-android/blob/master/messaging/app/src/main/AndroidManifest.xml

like image 78
Mateusz Pryczkowski Avatar answered Sep 20 '22 12:09

Mateusz Pryczkowski


It's not related to Firebase. Starting with Android 3.0 status icons were revised, and "are composed simply of white pixels on a transparent backdrop, with alpha blending used for smooth edges and internal texture where appropriate" https://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html. From what I've seen, starting Android 5.0 you are forced to provide these all white small status icons otherwise the gray square icon shows up.

This question Icon not displaying in notification: white square shown instead has answers that explain further and also show how to force your app to use the original ic_launcher icon although that doesn't seem like a good idea to me since you are forcing it to target an older sdk and also not following material design guidelines.

What you really should do is provide the small white icons which you can generate here http://romannurik.github.io/AndroidAssetStudio/icons-notification.html add them to your project and then configure FCM to use them as explained in the accepted answer

<meta-data
    android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/ic_stat_ic_notification" />
<meta-data
    android:name="com.google.firebase.messaging.default_notification_color"
    android:resource="@color/colorAccent" />
like image 34
obernal Avatar answered Sep 19 '22 12:09

obernal