In this blog, I will show you how to use Firebase Console Message (FCM) push notification in C#. First We have to understand what is Firebase Console Message. After that we implement Push notification step by step using Firebase Console message in C#.
What is the Firebase Console Message?
Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably send messages at no cost.
Using FCM, you can notify a client app that a new email or other data is available to sync. You can send notification messages to drive user re-engagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app. You can send your custom payload or predefined tags for notification.
Before you begin with the code, We want the Web API Key and Sender Id of the Firebase Project. You can get it from here – Click here
After Selection of the project. Click on Project settings
Get Project Web API Key from general tab
Get Project Sender Id from Cloud messaging tab
You have to use that project credentials used in your Application for generating the firebase token. If you get it another project credentials than notification will be not sent.
If you want to understand how to implement Firebase in your android application and how to generate a firebase token than you can follow this blog – Click here
Let’s now jump it on coding to send notification
There are two ways you can send payload to user :-
Notification to the user:- For sending notification you have to use predefined tags in the payload.
- title – notification title
- body – notification body
- link – When click on notification user redirect to this link
You can send notification to single user or 1000 user in a single time.
For single user you have to use ‘to’ tag with user fcm.
For multiple users, you have to use ‘registration_ids’ in which you have to provide fcm token array of users.
Send data to the user:- In this method you can use your custom tags in payload. You don’t have to rely on the predefined tags.
Use the below code for send notification in C#.
Don’t forget to change the Server API Key and Sender Id.
I hope, now you can send notification to the user easily. If you can’t understand something in this blog or you got an error in code, You can watch my video tutorial which will help you.
I would like to hear your thoughts or suggestions in the comment section.