Skip to content

Collection of c# common functions which we use to write or copy paste in every dotnet solution.

License

Notifications You must be signed in to change notification settings

musmanrafiq/dotnethelpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dot Net Helpers

NuGet Package

FirebaseNotifications

NuGet Package

To use firebase notifications package there are two scenarios :

1 - We have only one server key to use for sending notifications

In that case add one property i.e. ServerKey in your {config}.json file in your project like

"FirebaseMessaging" : 
{ "ServerKey" : "YOUR SERVER KEY HERE" 
} 

And next step is to add RegisterFirebaseMessaging(configuration); in your startup.cs file. Third and last step is to inject IFirebaseNotificationService in your class where you want to use it i.e.

private readonly IFirebaseNotificationService firebaseMessagingService; 
public MyClass(IFirebaseNotificationService firebaseMessagingService){ this.firebaseMessagingService = firebaseMessagingService; } 

// use firebaseMessagingService to call methods where required

// if you have device ids and only have one serverkey 
await firebaseMessagingService.SendNotification(deviceIds, "message", "title"); 

// if you have device ids and only have one serverkey and want to send to specific topic
await firebaseMessagingService.SendNotification(deviceIds, "message", "title", "my topic");

2 - We have multiple server keys ( multiple projects to support ) to use for sending notifications In that case we don't need update {config}.json file

just add RegisterFirebaseMessaging(configuration); in Startup.cs 

// if you are supporting multiple server keys ( firebase projects ), and have device ids 
await firebaseMessagingService.SendNotification(serverKey, "message", "title", deviceIds); 

// if you are supporting multiple server keys ( firebase projects ), and have a topic 
await firebaseMessagingService.SendNotification(serverKey, "message", "title", "topic");

About

Collection of c# common functions which we use to write or copy paste in every dotnet solution.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages