• 7
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

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.

My config.xml file looks like :

<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 know that when the app is opened it is it's responsability to display notifications. But I don't understand why the icon is changing ?

Thanks !

When the app is in foreground, it is its responsability to handle notification. I used FCM ionic plugin and handle push notifications directly. Problem solved.

  • 1
Reply Report