0
Posted on 6:20 AM by Softminer and filed under , ,

First download the sample here:
https://developer.xamarin.com/samples/monodroid/Firebase/FCMNotifications/

Then you have to create a project in Firebase
http://firebase.google.com

download google-services.json
right click on the google-service.json and set the Build Action vlaue to GoogleServicesJson



when your app is running the device get the token.

To send notification to device you need serverkey which you get from firebase server and token which you get from device in running mode

To send by postmann



you can write small c# code to post to sever by webclient:


using (var client = new WebClient())
     {
        var values = "{\"to\" : \"toekn",\"notification\" : {\"body\" : \"test\",\"title\" : \"title\",\"icon\" : \"myicon\"}}";
         client.Headers.Set("Content-Type", "application/json");
          client.Headers.Set("Authorization", "key=serverkey");
         var response = client.UploadString("https://fcm.googleapis.com/fcm/send", values);
         }


Using Microsoft Azure

using System;
using Microsoft.Azure.NotificationHubs;

namespace SendToNotificationHub
{
    class Program
    {
        public static string connectionString = "Endpoint=sb://app.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=yourkey";
        public static string NotificationHubPath = "your-hub";

        static void Main(string[] args)
        {
            SendNotificationAsync();
            Console.ReadLine();
        }


        private static async void SendNotificationAsync()
        {
            NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString
            (connectionString, NotificationHubPath);
            var alert = "{\"aps\":{\"alert\":\"Hi!\"}}";
            await hub.SendAppleNativeNotificationAsync(alert);
        }
    }
}
0
Responses to ... Xamarin Push notification using FireBase