Push color instead of icon when app is opened


#1

Hello @Ionic community !

I’m facing a problem with notification icons with firebase : when the app is in background, notifications are displayed with custom icon as desired ; but when the app is opened, a color is displayed instead of the icon, as you can see below (the first notification was send when app was closed) :

My config.xml file :

    <platform name="android">
[...]
        <resource-file src="resources/android/notification/drawable-hdpi/ic_stat_app.png" target="app/src/main/res/drawable-hdpi/notification_icon.png" />
        <resource-file src="resources/android/notification/drawable-mdpi/ic_stat_app.png" target="app/src/main/res/drawable-mdpi/notification_icon.png" />
        <resource-file src="resources/android/notification/drawable-xhdpi/ic_stat_app.png" target="app/src/main/res/drawable-xhdpi/notification_icon.png" />
        <resource-file src="resources/android/notification/drawable-xxhdpi/ic_stat_app.png" target="app/src/main/res/drawable-xxhdpi/notification_icon.png" />
        <resource-file src="resources/android/notification/drawable-xxxhdpi/ic_stat_app.png" target="app/src/main/res/drawable-xxxhdpi/notification_icon.png" />
        <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
    </platform>

Icons were generated with : https://romannurik.github.io/AndroidAssetStudio/icons-notification.html

The icon name is mentioned in notification data as below :

  var message = {
    notification: {
      body: event.messageBody,
      title: event.messageTitle
    },
    android: {
      notification: {
        body: event.messageBody,
        title: event.messageTitle,
        sound: 'default',
        icon: 'notification_icon',
        color: event.notificationColor
      }
    },
    token: registrationToken
  };

I thought about custom CSS, Android manifest configuration… but did’nt find anything. Does someone has an idea ?

Thanks ! :wink:


#2

Any idea here ? :cry: