# NotificationService

ABP version (opens new window) NuGet (opens new window) NuGet Download (opens new window) Discord online (opens new window) GitHub stars (opens new window)

An integrated user notification service Abp module, supporting email, SMS, PM, and more other methods.

# Online Demo

We have launched an online demo for this module: https://notification.samples.easyabp.io (opens new window)

# Installation

  1. Install the following NuGet packages. (see how (opens new window))

    • EasyAbp.NotificationService.Application
    • EasyAbp.NotificationService.Application.Contracts
    • EasyAbp.NotificationService.Domain
    • EasyAbp.NotificationService.Domain.Shared
    • EasyAbp.NotificationService.EntityFrameworkCore
    • EasyAbp.NotificationService.HttpApi
    • EasyAbp.NotificationService.HttpApi.Client
    • (Optional) EasyAbp.NotificationService.MongoDB
    • (Optional) EasyAbp.NotificationService.Web
    • (Optional) EasyAbp.NotificationService.Provider.Mailing
    • (Optional) EasyAbp.NotificationService.Provider.PrivateMessaging
    • (Optional) EasyAbp.NotificationService.Provider.Sms
    • (Optional) EasyAbp.NotificationService.Provider.WeChatOfficial
  2. Add DependsOn(typeof(NotificationServiceXxxModule)) attribute to configure the module dependencies. (see how (opens new window))

  3. Add builder.ConfigureNotificationService(); to the OnModelCreating() method in MyProjectMigrationsDbContext.cs.

  4. Add EF Core migrations and update your database. See: ABP document (opens new window).

# Usage

You can create a notification using a notification factory or manually.

# Create with Notification Factory

  1. Create a factory.

    public class UserWelcomeNotificationFactory
        : NotificationFactory<UserWelcomeNotificationDataModel, CreateSmsNotificationEto>, ITransientDependency
    {
        public override async Task<CreateSmsNotificationEto> CreateAsync(
            UserWelcomeNotificationDataModel model, IEnumerable<Guid> userIds)
        {
            var text = $"Hello, {model.UserName}, here is a gift card code for you: {model.GiftCardCode}";
    
            return new CreateSmsNotificationEto(CurrentTenant.Id, userIds, text, new Dictionary<string, object>());
        }
    }
    
  2. Use the factory to create a notification and publish it.

    var eto = await userWelcomeNotificationFactory.CreateAsync(
        model: new UserWelcomeNotificationDataModel(userData.UserName, giftCardCode),
        userId: userData.Id
    );
    
    await distributedEventBus.PublishAsync(eto);
    

# Create Manually

Publish the notification.

await distributedEventBus.PublishAsync(
    new CreateEmailNotificationEto(CurrentTenant.Id, userIds, subject, body));

Notifications

# Providers

# Q&A

# How to Change User's Email Address and Phone Number Info Source

You can override the IdentityUserEmailAddressProvider (opens new window) and the IdentityUserPhoneNumberProvider (opens new window).

# How to Use a Dynamic Notification Content Template

You can use the ABP Text Templating (opens new window) feature, see the demo (opens new window).

# Road map

  • [x] Private messaging notification provider.
  • [x] WeChat official template message notification provider.
  • [ ] WeChat mini-program subscribe message notification provider.
  • [ ] Notification management UI.
Last Updated: 11/18/2022, 9:10:36 AM