Skip to content

Notifications (OrchardCore.Notifications)

The Notifications module offers a comprehensive infrastructure for managing notifications effectively. It includes a centralized notification center and streamlined mechanisms for seamlessly dispatching notifications to users within the application.

Configurations

You can customize the default notification options through the configuration provider using the following settings:

"OrchardCore_Notifications": {
    "TotalUnreadNotifications": 10,
    "DisableNotificationHtmlBodySanitizer": false
}

Notification Methods

There are many methods to send notifications to a user (e.x., Email, Web Push, Mobile Push, SMS, etc.) Any notification sent will be centralized in the notification center before being dispatched to users according to their specified preferences.

Info

When multiple notification methods are enabled, the user can opt-in/out any method they wishes to receive by editing their profile.

Email Notifications

The Email Notifications feature offers a means to inform users by dispatching notifications through email.

Note

When using Email Notifications feature, you must also configure the Email Service.

SMS Notifications

The SMS Notifications feature offers a means to inform users by dispatching notifications through phone via SMS provider.

Note

When using SMS Notifications feature, you must also configure the SMS Services.

Adding Custom Notification Provider

To add a new notification method like Web Push, Mobile Push or SMS, you can simply implement the INotificationMethodProvider interface. Then, register your new implementation. For example, in the Email Notifications feature we register the email notification provider like this

[Feature("OrchardCore.Notifications.Email")]
public class EmailNotificationsStartup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<INotificationMethodProvider, EmailNotificationProvider>();
    }
}

How to send a notification

You can send notification to a user via code by injecting INotificationService then calling the SendAsync(...) method. Alternatively, you can use workflows to notify a user about an event that took place.

Workflow Activities

When OrchardCore.Workflows feature is enabled, you'll see new activities that would allow you to notify users using workflows. Here are some of the available workflow tasks

  • Notify Content's Owner Task
  • Notify User Task

Videos