Skip to main content

Notifications

This guide covers native desktop notifications in InfiniFrame: simple fire-and-forget notifications, rich notifications with action buttons and custom icons, and platform-specific behavior.

Notifications are implemented as a window feature. For an overview of the feature system, see Window Features Architecture. For message boxes (which are also part of this feature), see the Notifications feature API.

Contents​

Quick Start​

using InfiniFrame;

var window = InfiniFrameWindowBuilder.Create()
.SetTitle("My App")
.EnableNotifications(true)
.SetNotificationRegistrationId("com.example.myapp")
.SetStartPageUrl("https://myapp.local")
.Build();

// Simple fire-and-forget
window.ShowNotification("Build finished", "All tasks completed.");

window.WaitForClose();

Builder Configuration​

Notifications must be enabled during window construction. The builder provides two configuration methods:

var builder = InfiniFrameWindowBuilder.Create()
.EnableNotifications(true) // Enable/disable (default: true)
.SetNotificationRegistrationId("com.example.myapp") // Windows app identity
.SetDefaultNotificationIcon("/path/to/icon.png"); // Default icon for all notifications

IInfiniFrameWindow window = builder.Build();
MethodDescriptionDefault
EnableNotifications(bool)Enables or disables native notificationstrue
SetNotificationRegistrationId(string)Windows toast app identity (creates Start Menu shortcut)None
SetDefaultNotificationIcon(string)Default icon path for notifications without an explicit iconNone

Simple Notifications​

The basic ShowNotification method sends a fire-and-forget notification with a title and body:

window.ShowNotification("Update available", "A new version is ready to install.");

This is available both through the feature interface and as a fluent extension method:

// Via feature interface
window.Features.Notifications.ShowNotification("Title", "Body");

// Via extension method (returns window for chaining)
window.ShowNotification("Title", "Body");

Rich Notifications​

Use InfiniFrameNotificationOptions to configure notifications with custom icons, urgency levels, action buttons, and tags:

window.ShowNotification(new InfiniFrameNotificationOptions {
Title = "Download Complete",
Body = "report.pdf has been downloaded successfully.",
IconPath = "/path/to/icon.png",
Urgency = InfiniFrameNotificationUrgency.Normal,
Tag = "download-complete",
Actions = [
new InfiniFrameNotificationAction("Open", "open"),
new InfiniFrameNotificationAction("Show in Folder", "show-folder")
]
});

Options Reference​

PropertyTypeDescription
TitlestringRequired. Notification title
BodystringRequired. Notification body text
IconPathstring?Optional. Path to an image file
UrgencyInfiniFrameNotificationUrgencyOptional. Normal, Low, High, or Critical
ActionsIReadOnlyList<InfiniFrameNotificationAction>Optional. Action buttons
Tagstring?Optional. Group/replace previous notifications

Urgency Levels​

LevelWindowsLinuxmacOS
NormalDefault audioNOTIFY_URGENCY_NORMALActive interruption
LowSilentNOTIFY_URGENCY_LOWPassive interruption
HighDefault audioNOTIFY_URGENCY_CRITICALTime-sensitive interruption
CriticalLooping audioNOTIFY_URGENCY_CRITICALCritical interruption (requires entitlement)

Async Notifications with Callbacks​

Use ShowNotificationAsync to await user interaction with the notification:

InfiniFrameNotificationActivation result = await window.ShowNotificationAsync(
new InfiniFrameNotificationOptions {
Title = "New message",
Body = "You have a new message from Alice.",
Actions = [
new InfiniFrameNotificationAction("Reply", "reply"),
new InfiniFrameNotificationAction("Dismiss", "dismiss")
]
},
cancellationToken
);

switch (result.Result) {
case InfiniFrameNotificationResult.ActionClicked:
Console.WriteLine($"Action clicked: {result.ActionIdentifier}");
break;
case InfiniFrameNotificationResult.BodyClicked:
Console.WriteLine("Notification body clicked");
break;
case InfiniFrameNotificationResult.Dismissed:
Console.WriteLine("Notification dismissed");
break;
case InfiniFrameNotificationResult.TimedOut:
Console.WriteLine("Notification timed out");
break;
}

Result Types​

ValueDescription
DismissedNotification was dismissed without activation
BodyClickedUser clicked the notification body
ActionClickedUser clicked an action button (ActionIdentifier identifies which)
TimedOutNotification expired before user interaction
FailedPlatform error prevented display

JavaScript Bridge​

The JavaScript API supports notification commands through window.infiniframe.host.postData:

// Simple notification
window.infiniframe.host.postData({
id: "notifications/showNotification",
command: "Post",
data: {
title: "Hello from JS",
body: "This is a JavaScript notification"
},
version: 2
});

// Rich notification with options
window.infiniframe.host.postData({
id: "notifications/showNotification",
command: "Post",
data: {
title: "Rich notification",
body: "With icon and urgency",
iconPath: "/path/to/icon.png",
urgency: "High",
tag: "js-notification"
},
version: 2
});

Platform Support​

FeatureWindowsLinuxmacOS
Basic notification✅✅✅
Custom icon✅❌ (uses app icon)✅
Urgency levels⚠️ (audio option)✅✅ (macOS 12+)
Action buttons✅ (up to 5)❌❌
Notification tagging✅❌✅
Sound✅✅✅
Async callbacks✅✅✅

Platform Limitations​

Windows​

  • Requires Windows 10 or later
  • SetNotificationRegistrationId creates a Start Menu shortcut for toast notification identity
  • Action buttons are supported but async callbacks receive results immediately (toast handler brings window to foreground on any activation)
  • WinToastLib must be compatible with the Windows version

Linux​

  • Uses libnotify (typically GNOME or KDE notification daemon)
  • No action button support through libnotify
  • No custom icon support (uses the GTK window icon)
  • Notification urgency is mapped to libnotify urgency levels

macOS​

  • Uses UNUserNotificationCenter
  • Urgency levels require macOS 12+ (Monterey) for interruption levels
  • Custom icons are supported via notification attachments
  • Tag maps to the notification request identifier for grouping
  • Critical notifications require a special entitlement from Apple

Message Box​

The Notifications feature also provides native message box dialogs:

var result = window.ShowMessage(
title: "Confirm",
text: "Are you sure you want to quit?",
buttons: InfiniFrameDialogButtons.YesNo,
icon: InfiniFrameDialogIcon.Question
);

if (result == InfiniFrameDialogResult.Yes) {
window.Close();
}

Async version​

var result = await window.ShowMessageAsync(
title: "Confirm",
text: "Are you sure you want to quit?",
buttons: InfiniFrameDialogButtons.YesNo,
icon: InfiniFrameDialogIcon.Question
);

Dialog buttons​

ValueDescription
OkOK button only
OkCancelOK and Cancel buttons
YesNoYes and No buttons
YesNoCancelYes, No, and Cancel buttons

Dialog icons​

ValueDescription
InfoInformation icon
WarningWarning icon
ErrorError icon
QuestionQuestion icon

See Also​