In developing mobile web backends you might need users to broadcast messages such as push notifications to single or all mobile subscribers from the cloud using services like Firebase Cloud Messaging (FCM).
In this article we will focus on sending push notifications from a .Net application using Firebase.Notification library. This library makes it very easy to send push notifications from Firebase using C#
You can get more information of the library
here. You can also contribute
here
To begin, download the library from Nuget:
- Install-Package Firebase.Notification -Version 1.0.0
Using the library:
- using (var firebase = new Firebase())
- {
- firebase.ServerKey = "{Your Server Key}";
- var id = "{Your Device Id}";
- firebase.PushNotifyAsync(id,"Hello","World").Wait();
- Console.ReadLine();
- }
Error Handling and Debugging
Trace errors in your output window, all errors from this library will be captured under the category Firebase.Notification for easy debugging,