Search code examples
firebase-cloud-messagingfirebase-admin

How to add "priority" field at root level using FirebaseSDK in .Net core


using FirebaseAdmin(2.3.0) package to send push notification. In Androi, quit state of app,

when send push notification it doesn't wake up the app. "priority" field only exist in AndroidConfig in FirebaseSDK but I need it to be in root level currently my code;

using Message = FirebaseAdmin.Messaging.Message;
...

 var pushMessage = new Message()
                    {
//should be "priority" field at this level..
                        Token = item.Token,
                        Android = new AndroidConfig
                        {
                            Priority = Priority.High,
                       };
...

When I try to send data as instructed here it works..

So question is how can I build same data model using FirebaseAdmin in .NetCore

{
  "android": {
    "priority": "high"
  },
  "priority": 10 // need to add this.
}

Solution

  • priority can only be set in android method. Setting it to high should deliver the message even if the device is in Doze mode. Different platforms have unique headers for priority (e.g. apns-priority for iOS, Urgency for web) so setting in root level is not possible.