I'm using Firebase push notifications in my app that come from a server. When the app is in foreground, the correct notification icon is displayed. But when the app is in background, there's a filled circle instead of the notification icon.
I have looked at similar issues, and I am using the correct values in my manifest. Here's what I have in my manifest:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_name" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorPrimary" />
The notification color value seems to be working correctly. The filled circle is that of my app's primary color, and if I change it to some random RGB value, it updates. But the notification icon is always a filled circle no matter what.
And here is how I'm handling my notifications when in foreground, but that works correctly:
private fun showNotification(notification: RemoteMessage) {
createNotificationChannel()
val notificationId = notification.data["notificationId"]
val feedItemId = notification.data["itemId"]
val feedType = notification.data["type"]
val intent = Intent(this, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
putExtra(EXTRA_NOTIFICATION, true)
putExtra(EXTRA_NOTIFICATION_ID, notificationId)
putExtra(EXTRA_NOTIFICATION_FEED_ITEM_ID, feedItemId)
putExtra(EXTRA_NOTIFICATION_FEED_TYPE, feedType)
}
val pendingIntent = PendingIntent.getActivity(this, (0..1000).random(), intent, PendingIntent.FLAG_ONE_SHOT)
val builder = NotificationCompat.Builder(this, getString(R.string.notification_channel_id))
.setSmallIcon(R.drawable.ic_stat_name)
.setContentTitle(notification.notification?.title ?: "")
.setContentText(notification.notification?.body ?: "")
.setStyle(NotificationCompat.BigTextStyle()
.bigText(notification.notification?.body ?: ""))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
with(NotificationManagerCompat.from(this)) {
notify(System.currentTimeMillis().toInt(), builder.build())
}
}
So the notification icon is not the problem (as suggested in similar questions), as it displays correctly when the app is in foreground.