设置 Fcm 通知优先级 - Azure 通知中心 [英] Setting Fcm Notification Priority - Azure Notification Hub

查看:28
本文介绍了设置 Fcm 通知优先级 - Azure 通知中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 C# SDK 中为 Fcm 通知负载设置高优先级,以便从后端向其发送移动应用程序.根据 Fcm 文档,Json Paylod 应如下所示:

I am trying to set High Priority on an Fcm Notification Payload in C# SDK in order to send it the a mobile application from the Back-End. Standing to the Fcm Documentation the Json Paylod should look like this:

{
  "message":{
    "topic":"subscriber-updates",
    "notification":{
      "body" : "This week's edition is now available.",
      "title" : "NewsMagazine.com",
    },
    "data" : {
      "volume" : "3.21.15",
      "contents" : "http://www.news-magazine.com/world-week/21659772"
    },
    "android":{
      "priority":"normal"
    },
    "apns":{
      "headers":{
        "apns-priority":"5"
      }
    },
    "webpush": {
      "headers": {
        "Urgency": "high"
      }
    }
  }
}

在此处找到

在我的代码中,我尝试了不同的方法来使用 Azure SDK 来做到这一点.1

In my code i tried diffent ways to do that with the Azure SDK. 1

var result = await voipClient.SendFcmNativeNotificationAsync(payload, tag);

把这个json作为payload

Putting as payload this json

{
   "data":{
      "key":"value"   
},
   "android":{
      "priority":"high"

}

2

var notification = new FcmNotification(payload);
notification.Headers.Add("android", "{"priority": "high"}");

将广告有效载荷放在我之前发布的那个

Putting ad payload the one i posted before

在这两种情况下,我都会收到具有正常优先级的通知.

In both cases i receive the notification with normal priority.

你知道我哪里出错了吗?

Do you know where i'm making mistakes?

推荐答案

如果您查看 Azure 通知中心文档,您可能会感到困惑,因为它链接到 FCM 文档:FCM 允许以不同的方式构建有效负载,通知中心更为严格.

If you look at Azure Notification Hub documentation you could get confused because it links to FCM documentation: FCM allows different ways to build the payload, Notification Hub is stricter.

您应该发送以下有效负载:

You should send the following payload:

{
   "data":{
      "key1":"value1",
      "key2":"value2",

   },
  "priority":"high"
}

您发送到通知中心的负载实际上是 Firebase 负载中的android"字段.

The payload you send to Notification Hub is in fact the "android" field inside the Firebase payload.

注意:如果您将通知字段中的标题设置为如下所示,则通知中心会自动将优先级设置为:

Note: The priority is set automatically to high by Notification Hub if you set the title inside the notification field as follow:

{
  "notification": {
    "title":"any title"
  }
}

这篇关于设置 Fcm 通知优先级 - Azure 通知中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆