[英]Firebase Push Notification how to set icon? Using Admin SDK in .NET
基本上我想使用 Firebase 在推送通知上设置图标。 我正在使用他们的 Firebase Admin .NET SDK。 除了一个小细节之外,它实际上工作得很好,我无法设置图标。 利用类FirebaseAdmin.Messaging.Message
然后指定属性Token
然后指定Notification
对象(具有三个属性):
设置这些后,推送通知工作正常,但ImageUrl
是带有消息而不是图标的实际图像。 我想设置图标。 在查看文档后,我注意到Message
有一个名为Webpush
的属性,其类型为WebpushConfig
,该属性具有类型为WebpushNotification
的属性Notification
和boom! 那里有一堆设置,如 Tile、Body、Vibrate 等,但我真正想要的是Icon
。 不幸的是,为WebpushNotification
设置属性似乎没有任何作用。 这是我的代码。
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"
}
}
});
}
基本上只有FirebaseAdmin.Messaging.Notification work.
的三个属性FirebaseAdmin.Messaging.Notification work.
但是FirebaseAdmin.Messaging.WebpushNotification
的属性我无法开始工作,我只想要那里的Icon
。
这是文档
谢谢你。
将以下内容添加到 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.