Some people have also liked this question, so thought of providing the solution I implemented, thinking it may help others. Please feel free to ask questions, if you have any.
How to get the Server Key: Here is the question link which helps.
Firebase Cloud Messaging Documentation can be found here.
public class FirebaseNotificationModel
{
[JsonProperty(PropertyName = "to")]
public string To { get; set; }
[JsonProperty(PropertyName = "notification")]
public NotificationModel Notification { get; set; }
}
using System.Net.Http;
using System.Text;
public static async void Send(FirebaseNotificationModel firebaseModel)
{
HttpRequestMessage httpRequest = null;
HttpClient httpClient = null;
var authorizationKey = string.Format("key={0}", "YourFirebaseServerKey");
var jsonBody = SerializationHelper.SerializeObject(firebaseModel);
try
{
httpRequest = new HttpRequestMessage(HttpMethod.Post, "https://fcm.googleapis.com/fcm/send");
httpRequest.Headers.TryAddWithoutValidation("Authorization", authorizationKey);
httpRequest.Content = new StringContent(jsonBody, Encoding.UTF8, "application/json");
httpClient = new HttpClient();
using (await httpClient.SendAsync(httpRequest))
{
}
}
catch
{
throw;
}
finally
{
httpRequest.Dispose();
httpClient.Dispose();
}
}