[英]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.