I've found similar problems regarding small icons on android notifications, but Google won't give me any hints to following issue:
Simply and short, my notifications won't show color and icon when the app is not opened, but it'll work perfectly while the app is visible on the screen.
App is running in background when notification appears:
App is visible on the screen when notification appears:
For me it seems that the service fails to load some resources with its current context. Currently I'm using my own python server calling the firebase REST Api for sending the notifications.
While Title and Text-Body are sent directly via the notification's own payload, the icon and color are chosen by the app.
This is how the notification is built in the service.
final Context context = this.getApplicationContext();
final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setDefaults(Notification.DEFAULT_SOUND)
.setContentTitle(notification.getTitle())
.setContentText(notification.getBody())
.setColor(ContextCompat.getColor(context, R.color.notification))
.setSmallIcon(R.drawable.ic_local_shipping_white_24dp);
And this is the snippet for eventually showing the notification:
final NotificationManagerCompat mNotificationManager = NotificationManagerCompat.from(context);
final boolean notificationsEnabled = mNotificationManager.areNotificationsEnabled();
if (notificationsEnabled) {
mNotificationManager.notify(notifyID, mBuilder.build());
}
I appreciate your help!