Cordova-plugin-firebase: Notification ICON

Created on 21 Jun 2017  路  9Comments  路  Source: arnesson/cordova-plugin-firebase

The folder projectroot>/res/native/android/res/ folders doesn'r appear anymore in this cordova version. The folder native doesnt exist. Where should I put my notification_icon?

Most helpful comment

since you use firebase notification message(not pure data message), onMessageReceived will not call when the app is in the background,
so for this kind of notification , you should use

\ android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="drawable/ic_stat_ic_notification" \/\>

android:name="com.google.firebase.messaging.default_notification_color"
android:resource="color/colorAccent" \/\>

at AndroidManifest.xml

see https://firebase.google.com/docs/cloud-messaging/android/client
and https://firebase.google.com/docs/cloud-messaging/android/receive

All 9 comments

+1, I do not understand where to put the android notification_icon (and colors.xml)

My notification_icons are in this route:
platforms/android/res/drawable-sizeX/notification_icon.png

Yeah, mine too, but still not working. Doesn't appear the icont that I've set.

Try setting your icon in the request, like this:

{ 
  "notification" : {
      "title" : "title",
      "body" : "body",
      "color" : "#1f295d",          
      "sound":"default",
      "icon" : "notification_icon" <--------
    },
  "to": "eobfSAiF",
  "priority" : "normal"
}

If your app shows a white square instead of your icon check this: https://clevertap.com/blog/fixing-notification-icon-for-android-lollipop-and-above/

i've tried it too. I add the xmls files at the folders values and values-v21, and i've set the notification_icon.png into the folders in drwables folders, but when i trigger the notification just appear the white square.

@kelvinludwig The link works for me.

since you use firebase notification message(not pure data message), onMessageReceived will not call when the app is in the background,
so for this kind of notification , you should use

\ android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="drawable/ic_stat_ic_notification" \/\>

android:name="com.google.firebase.messaging.default_notification_color"
android:resource="color/colorAccent" \/\>

at AndroidManifest.xml

see https://firebase.google.com/docs/cloud-messaging/android/client
and https://firebase.google.com/docs/cloud-messaging/android/receive

@ml454 yes

check in the comment in the FirebasePluginMessagingService

````
// [START_EXCLUDE]
// There are two types of messages data messages and notification messages. Data messages are handled
// here in onMessageReceived whether the app is in the foreground or background. Data messages are the type
// traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app
// is in the foreground. When the app is in the background an automatically generated notification is displayed.
// When the user taps on the notification they are returned to the app. Messages containing both notification
// and data payloads are treated as notification messages. The Firebase console always sends notification
// messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
// [END_EXCLUDE]

````

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arunkatariaoodles picture arunkatariaoodles  路  4Comments

rolinger picture rolinger  路  5Comments

LKruglov picture LKruglov  路  4Comments

ghost picture ghost  路  3Comments

danielpalen picture danielpalen  路  5Comments