The DC Notification Service is a .NET 7 based library designed to simplify the process of sending various types of notifications such as emails, SMS, and push notifications. It abstracts the complexity of dealing with different notification providers and offers a unified interface to send notifications with just a few lines of code.
- Extensible Notification Providers: Easily integrate with any email, SMS, or push notification service provider.
- Runtime Provider Selection: Choose which notification service to use at runtime, offering flexibility for different environments and scenarios.
- Support for Multiple Notification Types: Emails with support for HTML content, multiple recipients, CC, and BCC; SMS notifications; Push notifications.
To get started with the DC Notification Service, install the package via NuGet, configure your service provider, and you're ready to send notifications.
Install the package with NuGet:
dotnet add package DC.NotificationService
Configure the services in your Startup.cs
:
public void ConfigureServices(IServiceCollection services)
{
// Configure your notification services here
services.AddEmailService(settings:new EmailSettings()
{
EnableSsl = true,
Host = "smtp-host",
Port = 2525,
Password = "mail-password",
Username = "mail-username",
From = "test@mail.com"
});
}
Inject the INotificationServiceFactory
to create and send notifications:
public class NotificationController : ControllerBase
{
private readonly INotificationServiceFactory _notificationFactory;
public NotificationController(INotificationServiceFactory notificationFactory)
{
_notificationFactory = notificationFactory;
}
public async Task<IActionResult> SendNotification()
{
EmailMessage emailMessage = new EmailMessage
{
To = new List<string> { "test@mail.com" },
Subject = "Welcome to DC Notification Service",
Content = "<p>This is a test email.</p>",
IsHtml = true
};
await _notificationFactory.SendEmail(emailMessage);
return Ok("Notification sent successfully.");
}
}
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
Don't forget to give the project a star :) Thanks again!
- Integrate Twilio for SMS notifications.
- Integrate MailChimp for email services.
- Integrate Firebase for push notifications.