Giter Club home page Giter Club logo

notificationservice's Introduction

NotificationService

ABP version NuGet NuGet Download Discord online GitHub stars

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

Installation

  1. Install the following NuGet packages. (see how)

    • 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)

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

  4. Add EF Core migrations and update your database. See: ABP document.

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
    );
    
    // use the distributed event bus to create notifications and send them in the background
    await distributedEventBus.PublishAsync(eto);
    // or use the integration service to create notifications and send them in the background
    var notifications = await notificationIntegrationService.CreateAsync(eto);
    // or use the integration service to create notifications and send it them immediately
    var notifications = await notificationIntegrationService.QuickSendAsync(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 and the IdentityUserPhoneNumberProvider.

How to Use a Dynamic Notification Content Template

You can use the ABP Text Templating feature, see the demo.

Road map

  • Private messaging notification provider.
  • WeChat official template message notification provider.
  • WeChat mini-program subscribe message notification provider.
  • Notification management UI.

notificationservice's People

Contributors

gdlcf88 avatar slarkerino avatar ngvanmy avatar indexlang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.