Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 746
Notification
github-actions[bot] edited this page Oct 31, 2025 · 1 revision
Show native desktop notifications with custom content and actions.
The Electron.Notification API provides the ability to show native desktop notifications with custom titles, bodies, icons, and actions. Notifications work across Windows, macOS, and Linux with platform-specific behavior.
Check if desktop notifications are supported on the current platform.
Returns:
Whether or not desktop notifications are supported on the current system.
Create OS desktop notifications with the specified options.
Parameters:
notificationOptions- Notification configuration options
// Simple notificationElectron.Notification.Show(newNotificationOptions{Title="My Application",Body="This is a notification message",Icon="assets/notification-icon.png"});// Notification with reply actionElectron.Notification.Show(newNotificationOptions{Title="New Message",Body="You have a new message from John",Icon="assets/message-icon.png",Actions=new[]{newNotificationAction{Text="Reply",Type=NotificationActionType.Button},newNotificationAction{Text="View",Type=NotificationActionType.Button}},OnClick=()=>OpenMessageWindow(),OnAction=(action)=>{if(action=="Reply"){ShowReplyDialog();}elseif(action=="View"){OpenMessageWindow();}}});// Rich notification with all optionsElectron.Notification.Show(newNotificationOptions{Title="Download Complete",Subtitle="Your file has finished downloading",Body="document.pdf has been downloaded to your Downloads folder.",Icon="assets/download-icon.png",ImageUrl="file://"+Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"assets/preview.png"),Sound=NotificationSound.Default,Urgency=NotificationUrgency.Normal,Category="transfer.complete",Tag="download-123",Actions=new[]{newNotificationAction{Text="Open",Type=NotificationActionType.Button},newNotificationAction{Text="Show in Folder",Type=NotificationActionType.Button}},OnShow=()=>Console.WriteLine("Notification shown"),OnClick=()=>OpenDownloadedFile(),OnClose=()=>Console.WriteLine("Notification closed"),OnAction=(action)=>{if(action=="Open"){OpenDownloadedFile();}elseif(action=="Show in Folder"){ShowInFolder();}}});// Windows toast notificationif(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)){Electron.Notification.Show(newNotificationOptions{Title="Background Task",Body="Your backup is complete",Icon="assets/app-icon.ico",Tag="backup-complete",RequireInteraction=true});}// macOS notification with soundelseif(RuntimeInformation.IsOSPlatform(OSPlatform.OSX)){Electron.Notification.Show(newNotificationOptions{Title="Alert",Body="Something needs your attention",Sound=NotificationSound.Default,Actions=new[]{newNotificationAction{Text="View",Type=NotificationActionType.Button}}});}// Check notification supportvarisSupported=awaitElectron.Notification.IsSupportedAsync();Console.WriteLine($"Notifications supported: {isSupported}");// Create notification with eventsvarnotification=newNotificationOptions{Title="Task Complete",Body="Your long-running task has finished",OnShow=()=>Console.WriteLine("Notification displayed"),OnClick=()=>OpenTaskResults(),OnClose=()=>Console.WriteLine("Notification dismissed")};Electron.Notification.Show(notification);- Electron.App - Application lifecycle events
- Electron.Tray - System tray integration with notifications
- Electron.Screen - Position notifications based on screen layout
- Electron Notification Documentation - Official Electron notification API
Want to contribute to this documentation? Please fork and create a PR! The Wiki is autogenerated from the /docs content in the repository.