1

So I have integrated Firebase Cloud Messaging in my Qt application and I am trying to set a custom icon for notifications (which by default displays a grayed out circle). I know that this question has been asked here before Notification Icon with the new Firebase Cloud Messaging system. Now I have followed the suggestions in the post (and other similar posts). In my manifest file I have added:

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

I then created different icons according to the specification for custom status bar icons provided by Google (white on transparent background). My target SDK is set to 26. Despite this however, the notifications always display the default icon and not my custom icon. I am sending the notifications from the Firebase Console website. I know that some users suggested to use the API to send notifications since it seems to solve this issue, but is it possible to avoid this and manage to succeed with the Firebase Console?

reckless
  • 741
  • 12
  • 53
  • "*Is it possible to avoid this and manage to succeed with the Firebase Console*" -- it's in the [docs](https://firebase.google.com/docs/cloud-messaging/android/receive#edit-the-app-manifest) that this could work. There's probably something else causing the app to ignore your icon. Are you absolutely sure that icon is within the guidelines for notification icons? – AL. Sep 26 '18 at 15:33
  • Yes, I am sure. I just double checked. – reckless Sep 27 '18 at 17:34

1 Answers1

1

Ok so I found a solution to my problem. The issue was that I was testing the application on Android 8.0 Oreo. From this version of Android, Google requires that application make use of Notification Channels and applications are required to create a default Notification Channel. So I added the following code to the main activity of my application in the onCreate method:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    // Create channel to show notifications.
    String channelId  = getString(R.string.default_notification_channel_id);
    String channelName = getString(R.string.default_notification_channel_name);
    NotificationManager notificationManager =
            getSystemService(NotificationManager.class);
    notificationManager.createNotificationChannel(new NotificationChannel(channelId,
            channelName, NotificationManager.IMPORTANCE_LOW));
}

Then added the default notification id in the manifest file:

<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="@string/default_notification_channel_id"/>
reckless
  • 741
  • 12
  • 53