[英]Firebase Push Notification how to set icon? Using Admin SDK in .NET
Basically I want to set the icon on the push notification using Firebase.基本上我想使用 Firebase 在推送通知上设置图标。 I am using their Firebase Admin .NET SDK.
我正在使用他们的 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):利用类
FirebaseAdmin.Messaging.Message
然后指定属性Token
然后指定Notification
对象(具有三个属性):
After setting those the push notification works fine, but the ImageUrl
is an actual image withing the message not the icon.设置这些后,推送通知工作正常,但
ImageUrl
是带有消息而不是图标的实际图像。 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!在查看文档后,我注意到
Message
有一个名为Webpush
的属性,其类型为WebpushConfig
,该属性具有类型为WebpushNotification
的属性Notification
和boom! there they are, a bunch of settings like Tile, Body, Vibrate and others, but the one I really want is in there Icon
.那里有一堆设置,如 Tile、Body、Vibrate 等,但我真正想要的是
Icon
。 Unfortunately setting the attributes for WebpushNotification
do not seem to do anything.不幸的是,为
WebpushNotification
设置属性似乎没有任何作用。 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.
基本上只有
FirebaseAdmin.Messaging.Notification work.
的三个属性FirebaseAdmin.Messaging.Notification work.
But the attributes from FirebaseAdmin.Messaging.WebpushNotification
I cannot get to work, I just want the Icon
from there.但是
FirebaseAdmin.Messaging.WebpushNotification
的属性我无法开始工作,我只想要那里的Icon
。
Thank you.谢谢你。
add the following to AndroidManifest.xml file将以下内容添加到 AndroidManifest.xml 文件中
<!-- 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" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.