问题
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"
}
}
}
}
Found here
In my code i tried diffent ways to do that with the Azure SDK. 1
var result = await voipClient.SendFcmNativeNotificationAsync(payload, tag);
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?
回答1:
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"
}
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"
}
}
来源:https://stackoverflow.com/questions/60508039/setting-fcm-notification-priority-azure-notification-hub