LaunchBoxContributors
On this page

INotificationManager14.1

Interface in Unbroken.LaunchBox.Plugins.Services.Notifications

C#
public interface INotificationManager
Provides plugin access to the LaunchBox notification system. A plugin can request this service by declaring a public constructor with an INotificationManager parameter.

Remarks

Notifications respect the style that the user has selected under Options. Plugins cannot force a particular presentation style. Big Box does not currently provide a notification system, so operations return an unavailable result there.

Messages and action labels accept a required fallback through PluginText and an optional package string-resource key. LaunchBox selects the user's language and formats any supplied values.

LaunchBox visibly attributes notifications to the requesting plugin. The default image comes from the plugin manifest or the conventional plugin.icon package image resource; no image is displayed when neither is available. Plugins can select another image by resource ID, but cannot replace the host-controlled attribution.

Operations can be called from any thread. A returned task completes after LaunchBox has processed the request. When the selected presentation is a message box, that can include waiting for the user to dismiss it.

New notifications contribute to the unread count until the user reads or dismisses them. Plugins can observe that state but cannot change it.

An identical message is suppressed for five seconds after publication. Notifications are also subject to an overall rate limit and a 50-notification retention limit. A suppressed request returns a result instead of displaying another notification.

Argument validation and cancellation use normal .NET exceptions. Runtime presentation failures are reported through PluginNotificationResult.Status instead of being thrown. Added in LaunchBox 14.1.

Example

C#
PluginProgressNotificationResult result = await notifications.StartProgressAsync(
    new PluginProgressNotificationRequest(
        new PluginText("Importing {0:N0} games...", gameCount)
        {
            ResourceKey = "notifications.import.running"
        })
    {
        Icon = new PluginNotificationIcon("import.progress")
    },
    cancellationToken);
if (result.Notification is IPluginProgressNotification progress)
{
    await progress.CompleteAsync(
        new PluginProgressCompletionRequest("Import complete."),
        cancellationToken);
}

Methods

  • AddToNotificationCenterAsyncAdds a new unread notification to the LaunchBox notification center without displaying a popup.
  • ShowErrorAsyncDisplays a new unread error notification using the user's selected notification style.
  • ShowInfoAsyncDisplays a new unread informational notification using the user's selected notification style.
  • StartProgressAsyncStarts a new unread, updateable progress notification in the LaunchBox notification center without displaying a one-off system notification or message box.

AddToNotificationCenterAsync

C#
Task<PluginNotificationResult> AddToNotificationCenterAsync(
    PluginNotificationCenterRequest request,
    CancellationToken cancellationToken
)
Adds a new unread notification to the LaunchBox notification center without displaying a popup.
request
The notification message, severity, and presentation settings.
cancellationToken
A token used to cancel the operation.

Returns

The publication outcome and the notification handle, when published.

ShowErrorAsync

C#
Displays a new unread error notification using the user's selected notification style.
request
The notification message and display settings.
cancellationToken
A token used to cancel the operation.

Returns

The publication outcome and the notification handle, when published.

ShowInfoAsync

C#
Displays a new unread informational notification using the user's selected notification style.
request
The notification message and display settings.
cancellationToken
A token used to cancel the operation.

Returns

The publication outcome and the notification handle, when published.

StartProgressAsync

C#
Starts a new unread, updateable progress notification in the LaunchBox notification center without displaying a one-off system notification or message box.
request
The initial progress message and presentation settings.
cancellationToken
A token used to cancel the operation.

Returns

The publication outcome and an updateable notification handle, when published.