Firebase消息传送严重声音

uxhixvfz  于 2023-05-18  发布在  其他
关注(0)|答案(1)|浏览(111)

我已经用Firebase消息发送了通知。我想创建关键警报IOS通知,但我找不到firebase API的真实主体。我试过很多身体,比如:

"apns": {
      "headers": {
        "apns-priority": "5"
      },
      "payload": {
        "aps": {
             "sound":  {
            "name": "alert.mp3",
            "volume": 1,
            "critical": true
          }
        }
      }
    },

通知{

"sound":  {
    "name": "alert.mp3",
    "volume": 1.0,
    "critical": 1 // and true
  },
}

我有权限从IOS获取严重警报,并为IOS创建配置文件。但是,我无法创建严重警报。
我想为Firebase消息关键警报找到真实的身体。我尝试了这个代码从 Postman 与https://fcm.googleapis.com/fcm/send。我找不到解决办法。

gcuhipw9

gcuhipw91#

我也面临着同样的问题,我已经用以下方法解决了,我希望它也能为您工作:

Notification = new FirebaseAdmin.Messaging.Notification()
            {
                Title = "Test Message",
                Body = "You have a new Test message!"
            },
            Token = "your-device-token",
            //sound configurations for android
            Android = new AndroidConfig()
            {
                Notification = new AndroidNotification()
                {
                    Sound = "default", 
                    DefaultVibration = true,
                    Priority = Priority.High, 
                    Visibility = Visibility.Public, 
                    NotificationPriority=AndroidNotificationPriority.High, 
                   Category = "alarm", 
                   Color = "#FF0000", 
                   CriticalSound = new CriticalSound()
                  {
                    Name = "my_critical_sound", // Set the name of the critical sound
                    Volume = 1.0, // Set the volume of the critical sound (0.0 - 1.0)
                  },
                },
            },
            //sound configuration for ios
            Apns = new ApnsConfig()
            {
                Aps = new Aps()
                {
                    Sound = "default",
                },
            },

注意:我使用的是.NET 6,要实现上述方法,需要一个nuget包FirebaseAdmin,其中包含必需的类。更多细节请参考firebase的官方文档。
Link to Official Firebase Documentation
我希望这将有助于解决这个问题。

相关问题