How to create a Push Notification (FCM) using C#

Viewed 14066

I have a REST Api written in .NET Core, now has a requirement to create a Push Notification to Firebase Cloud Messaging (FCM). For testing, am using the Firebase Console but I need to get this done programtically. I have gone through the documentation of Firebase and some examples via Google but am more confused.

I think it is possible to create a message via a regular Http but can someone post a simple working example so that I can pick it up, please? Or maybe, my understanding is totally wrong?

2 Answers

With .NET Core you can use this lightweight library for FCM push notifications and APN HTTP/2 Push notifications:

Install-Package CorePush

And then for Firebase:

using (var fcm = new FcmSender(serverKey, senderId))
{
    await fcm.SendAsync(deviceToken, notification);
}

Or APN:

using (var apn = new ApnSender(privateKey, keyId, teamId, appbundleId, server)) 
{
    await apn.SendAsync(deviceToken, notification);
}
Related