Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FCM Notification icon is not being used

I am using FCM and I could successfully send push notification to my app. I want to use custom notification icon but it always show white icon. I am running Lollipop.

From the documentation it says

icon Optional, string Indicates notification icon. Sets value to myicon for drawable resource myicon.

( I'm not sure what exactly it means ). But here are what I did.

  1. I generated icons from here . It does have icons with only white text and transparent background. Sample screenshot pic of the icon is enter image description here

  2. I added to res folder enter image description here

  3. I edited my AndroidManifest and added this android:icon="@drawable/ic_stat_set" in <Application

  4. I tried running the project on the device, the new app icon ic_stat_set are being used as app launcher.

  5. From the console I send notification and I did receive it but its not the icon I just set.

  6. I also tried sending through api. I did received the notification but not the icon that i set.

    curl -X POST --header "Authorization: key=SERVERKEY" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"to\":\"REGISTERATION-TOKEN-ID\",\"notification\":{\"body\":\"Yellow\" , \"icon\" : \"ic_stat_set\"} \"priority":\"10"}"

UPDATE : my drawable icons files are https://drive.google.com/open?id=0B5Fi1l7EbQ_BOERUMzNuQy1OWXM

Do I have to put something in those custom data files in the console ? My icon ? What I am missing ?

Thanks

like image 616
cjmling Avatar asked Aug 24 '16 06:08

cjmling


People also ask

How do I test FCM push notifications?

Send a test notification messageOpen the Notifications composer and select New notification. Enter the message text. Select Send test message. In the field labeled Add an FCM registration token, enter the registration token you obtained in a previous section of this guide.

How do I use the notification icon in flutter?

try generate the icon for your notification using this link https://romannurik.github.io/AndroidAssetStudio/icons-notification.html then make sure you has defined the icon in your initializatuon, example for Android: const AndroidInitializationSettings('@drawable/ic_firebase_notification');

What is APN and FCM?

APNS Token is the Apple Push Notification Service token. It is a token (think of it like a password) that authenticates your app and device onto the Apple Push service and allows for communications to be sent. FCM Token is the Firebase Cloud Messaging token.


1 Answers

I think it might be your icon size for the status bar that is off

Take a look here.

https://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html

Your app icon should be different than your notification icon.

The icon param in the notification is for the status bar.

The icon param in the Manifest is for the app icon(Shortcut)

I recommend this sample

like image 154
Michael B. Avatar answered Nov 11 '22 21:11

Michael B.