Last update:
August 24, 2024
Extend Notification Types¶
Sometimes you might need to extend the existing notification type with new properties, or override the existing default template with some new ones.
To extend the existing notification, for example, SampleEmailNotification
:
-
Create a new notification class based on the notification type you want to extend:
-
Add the following line into the Module.cs file:
Module.cspublic void PostInitialize(IApplicationBuilder appBuilder) { ... var registrar = appBuilder.ApplicationServices.GetService<INotificationRegistrar>(); registrar.OverrideNotificationType<SampleEmailNotification, ExtendedSampleEmailNotification>() .WithTemplates(new EmailNotificationTemplate() { Subject = "Extended SampleEmailNotification subject", Body = "Extended SampleEmailNotification body test" }); ... }
Note
Running the .WithTemplates(new EmailNotificationTemplate()
extension method is optional and can be used in case you want to override the default templates.