5

I am using the Firebase .net Admin SDK on my back end to send push notifications.

According to this link I should be able to add the following json into a message object that will open the set link when the notification is clicked on while the app is in background.

  "webpush": {
    "fcm_options": {
      "link": "https://dummypage.com"
    }

I have read through the .net Admin Sdk documentation but cannot figure out where to add this. Here is the code that I used to new up the message object

var fcm = FirebaseAdmin.Messaging.FirebaseMessaging.DefaultInstance;
var Message = new Message()
  {
    Notification = new Notification
      {
        Title = title,
        Body = message,
      },
    Token = user.PushTokenWeb,
  };
var result = await fcm.SendAsync(Message);

Does anyone know where I would set the callback link?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Skbenga
  • 105
  • 1
  • 7

2 Answers2

4

In FirebaseAdmin .net v1.9.0 you can

    var message = new Message()
    {
        Token = token,
        Notification = new Notification()
        {
            Body = notificationBody,
            Title = title
        },
        Android = new AndroidConfig()
        {
            Priority = Priority.High
        },
        Webpush = new WebpushConfig()
        {
            FcmOptions = new WebpushFcmOptions()
            {
                 Link= "https://www.davnec.eu/aurora-boreale/previsioni/"
            }
        }

    };
Davide Necchi
  • 776
  • 7
  • 9
0

.NET SDK does not support this setting yet. It's only exposed in Node.js and Go at the moment. You can provide a pull request at https://github.com/firebase/firebase-admin-dotnet to implement this feature.

Hiranya Jayathilaka
  • 7,180
  • 1
  • 23
  • 34