C# Firebase推送通知如何设置图标?在.NET中使用AdminSDK
基本上,我想使用Firebase在推送通知上设置图标。我正在使用他们的Firebase Admin.NET SDK。除了一个小细节,它实际上工作得很好,我无法设置图标。使用类C# Firebase推送通知如何设置图标?在.NET中使用AdminSDK,c#,.net,firebase,push-notification,firebase-cloud-messaging,C#,.net,Firebase,Push Notification,Firebase Cloud Messaging,基本上,我想使用Firebase在推送通知上设置图标。我正在使用他们的Firebase Admin.NET SDK。除了一个小细节,它实际上工作得很好,我无法设置图标。使用类FirebaseAdmin.Messaging.Message然后指定属性令牌,然后指定通知对象(具有三个属性): 身体 图像URL 头衔 设置这些后,推送通知工作正常,但是ImageUrl是一个实际的图像,带有消息而不是图标。我想设置图标。查看文档后,我注意到Message有一个Webpush类型的属性WebpushCon
FirebaseAdmin.Messaging.Message
然后指定属性令牌
,然后指定通知
对象(具有三个属性):
ImageUrl
是一个实际的图像,带有消息而不是图标。我想设置图标。查看文档后,我注意到Message
有一个Webpush
类型的属性WebpushConfig
,它有一个Notification
类型的属性Notification
,然后爆炸!有很多设置,比如瓷砖、主体、振动和其他,但我真正想要的是图标。不幸的是,为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中的三个属性起作用。
但是FirebaseAdmin.Messaging.WebpushNotification的属性我无法工作,我只想从那里得到图标
这是你的电话号码
谢谢。将以下内容添加到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" />
或在发送通知之前设置图标属性:var msg=new Message(){Token=Token,notification=new notification(){Body=notificationBody,Title=Title,},Android=newandroidconfig(){Notification=newandroidnotification(){ClickAction=“flatter\u Notification\u CLICK”,Icon=“ic\u launcher”},}代码>