Introduction
In this article, we will be sending push notifications to Android devices via C# Dot Net/.Net. Using Firebase Cloud Messaging API HTTP V1.
This article will guide using of FCM HTTP V1 over Legacy FCM API.
The latest FCM Http V1 provides better security, Support for the new Client Platform version.
Section 1. Create/ Login in Firebase Console Account.
After creating of account/Login, Click on Add Project.
![Push Notification From C# .Net to Android]()
Section 2. Add Firebase to your Android project
Section 3. Go to Project Settings
![Push Notification From C# .Net to Android]()
Section 4. Enable FCM HTTP V1
![Push Notification From C# .Net to Android]()
Section 5. Create a .Net Web API project; write this code to generate a Bearer token for calling FCM HTTP V1 API.
![Push Notification From C# .Net to Android]()
Code
Section 6. Follow this Step to Download the Json file from the Firebase Console Account (Project Settings -> Service Account -> Generate New Private Key) & Place the Json File in your Project directory.
![Push Notification From C# .Net to Android]()
Section 7. Place the downloaded JSON File in your .net Project directory.
![Push Notification From C# .Net to Android]()
Section 8. Install Google.Api.Auth from Nuget Package Manager
![Push Notification From C# .Net to Android]()
Section 9. Use the Authorization token generated above via c# code to call FCM HTTP V1 API; get the FCM Token of Android from an Android device. Test using Postman; a push notification will be sent to the Android device.
![Push Notification From C# .Net to Android]()
![Push Notification From C# .Net to Android]()
Section 10. On successful completion of the above steps, Implement Further, Create this Model Classes for storing Request & Response data.
![Push Notification From C# .Net to Android]()
Section 11. Call the FCM HTTP V1 API using the Authorization token generated & get the FCM id / Token from the Android device.
![Push Notification From C# .Net to Android]()
Section 12. Entire Code