繁体   English   中英

Firebase 推送通知如何设置图标? 在 .NET 中使用管理 SDK

[英]Firebase Push Notification how to set icon? Using Admin SDK in .NET

基本上我想使用 Firebase 在推送通知上设置图标。 我正在使用他们的 Firebase Admin .NET SDK。 除了一个小细节之外,它实际上工作得很好,我无法设置图标。 利用类FirebaseAdmin.Messaging.Message然后指定属性Token然后指定Notification对象(具有三个属性):

  1. 身体
  2. 图片网址
  3. 标题

设置这些后,推送通知工作正常,但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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM