Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FCM push notification showing white square icon instead of app icon when app is in Background

I am using FCM in my android app to manage push notification. Its completely working fine when the app is in foreground and the app icon is also visible(properly). But when the app is running in background I am not getting the notification properly. Instead of the transparent icon its showing the white square icon as the notification icon. I know that, FCM will automatically handle the background operation. But I need to show my app icon instead of that white icon. Note: I am using transparent icon only. I also tried the below coding

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

But none of the solutions actually worked for me. Can someone tell me what to do?

like image 873
Encipherer Avatar asked Nov 16 '16 12:11

Encipherer


People also ask

Why do my notifications not have an icon?

Navigate back to the main Settings screen, tap Notifications, and then tap Advanced settings. Tap the switch next to App icon badges to turn them on.

How do I change app notification icons?

1 Tap Notification Settings on the notification panel or tap the Settings app. 2 Tap Notifications. 3 Tap App icon badges.

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.


1 Answers

{
 "to" : "token",
  "notification": {"body": "Body",
"title": "Title",
"click_action": "com.sample.test.OPEN_ACTIVITY",
      "icon" : "ic_launcher"
},
 "data": {
    "image": "https://ibin.co/2t1lLdpfS06F.png",
    "message": "Firebase Push Message Using API"

  }
 }

So if the name of "icon" is the same as your file name in app drawable, FCM takes care of result, if your app is in background. In foreground its your own custom implementation of notification, which will work. Just leme know if, that solved the problem.

like image 119
Denny Mathew Avatar answered Sep 19 '22 12:09

Denny Mathew