Confinity Documentation
  • Latest Version
  • Latest Version
  • Getting Started

    • Introduction
    • Core Concepts
    • Create an Application
    • Glossary
  • Essentials

    • Authentication & SSO
    • Breaking Changes
    • Roslyn Source Analyzers
    • Changelog
    • ConfinityContent
    • ConfinitySelectable
    • Confinity Schedules
    • Data Seeding
    • Development guidelines [WIP]
    • Entity App
    • Entity Form
    • Entity Permissions
    • Frontend Configuration
    • Images
    • Known Issues
    • Localization
    • Migrations
    • Modules [WIP]
    • On-Site Editing
    • Settings
    • Cascade Delete
    • Replication
    • Infrastructure
  • Modules

    • Analytics Module
    • Assets Module
    • Blog Module
    • Cookie Consent Module
    • Forms Module
    • Friendly Captcha (Forms Module )
    • GeoIP Module
    • Htmx
    • Mail Module
    • Mailing Module
    • MediaPlayer Module
    • GoogleMyBusiness Module
    • OpenTelemetry Module
    • Pages Module [WIP]
    • Pattern Library Module
    • SIX Saferpay (worldline) Module
    • Products Module
    • Search Module
    • Wizard Module
  • Guides

    • Create a Custom Entity App Form Element
    • Date and Time
    • Entity Change Listener
    • File Upload / Temp File
    • HTTP security headers
    • conventions [WIP]
    • How to use Confinity with nginx
    • Notifications
    • Nullability
    • Rename Entity
    • Schedules
    • Useful snippets
    • Content Localization
  • Design Guidelines

    • Introduction
    • Page Components
    • Forms Module

Notifications

Confinity allows to send notifications to users. This is useful to inform the user about something that the system did that was not immediately requested by the user, e.g. the execution of a publishing task or a export job. The notification title and message can be localized.

Examples

For sending notifications you need to inject the INotificationService and call one of the overloads of SendAsync.

Simple notification

Use this overload when the notification just contains text.


_notificationService.SendAsync(receiver.Id, "Import finished.",
    "Your user import finished.");

Notification with link to entities

You can specify entities that can be linked to from your notification.


var users = new List<User>();
_notificationService.SendAsync(receiver.Id, "Import finished.",
    "Your data import finished.", users);

Notification with interpolated strings

For interpolated strings you need to implement your own NotificationPayload with public, serializable properties.


var payload = new ImportPayload { ImportedUsersNames = users.Select(p => p.Username).ToList() };
_notificationService.SendAsync(receiver.Id, payload, users);


public sealed class ImportPayload : NotificationPayload
{
    public ICollection<string> ImportedUsersNames { get; set; } = [];

    public override LocalizedText GetTitle()
    {
        int count = ImportedUsersNames?.Count ?? 0;
        return new LocalizedText("Import of {0} users finished.", count.ToString());
    }

    public override LocalizedText GetMessage()
    {
        if (ImportedUsersNames == null || ImportedUsersNames.Any())
            return new LocalizedText("Nothing was imported.");

        return new LocalizedText("Imported {0} and {1} others.", ImportedUsersNames.First(),
            (ImportedUsersNames.Count - 1).ToString());
    }
}

Prev
How to use Confinity with nginx
Next
Nullability