Basically I want to set the icon on the push notification using Firebase. I am using their Firebase Admin .NET SDK. Which actually works just fine except for one minor detail, I cannot set the icon. Utilizing the class FirebaseAdmin.Messaging.Message
then specifying the attribute Token
then specifying the Notification
object (which has three attributes):
After setting those the push notification works fine, but the ImageUrl
is an actual image withing the message not the icon. I want to set the icon. After look through the docs I noticed that Message
has an attribute called Webpush
of type WebpushConfig
which that has an attribute Notification
of type WebpushNotification
and boom! there they are, a bunch of settings like Tile, Body, Vibrate and others, but the one I really want is in there Icon
. Unfortunately setting the attributes for WebpushNotification
do not seem to do anything. Here is my code.
public async Task Push(string token)
{
await messaging.SendAsync(new Message() {
Token = token,
Notification = new Notification() {
//Title = "This Title works",
//Body = "This body works",
//ImageUrl = "someUrlThatWorks"
},
Webpush = new WebpushConfig()
{
Notification = new WebpushNotification
{
Title = "This title does not work",
Body = "This body does not work",
Icon = "thisIconDoesNotWork.png"
}
}
});
}
Basically only the three attributes from FirebaseAdmin.Messaging.Notification work.
But the attributes from FirebaseAdmin.Messaging.WebpushNotification
I cannot get to work, I just want the Icon
from there.
Here are the Docs
Thank you.
add the following to AndroidManifest.xml file
<!-- Set custom default icon. This is used when no icon is set for incoming notification messages. -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_ic_notification" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
notification message. -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.