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.
I generated icons from here . It does have icons with only white text and transparent background. Sample screenshot pic of the icon is
I added to res folder
I edited my AndroidManifest and added this android:icon="@drawable/ic_stat_set" in <Application
I tried running the project on the device, the new app icon ic_stat_set are being used as app launcher.
From the console I send notification and I did receive it but its not the icon I just set.
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
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.
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');
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With