Skip to content

ElectronNotification

Unofficial

Electron Notification for creating and showing native OS notifications.

Import:

import type { ElectronNotification } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export class ElectronNotification

Properties

Property Type Description
actions ElectronNotificationAction[] A NotificationAction[] property representing the actions of the notification.
body string A string property representing the body of the notification.
closeButtonText string A string property representing the close button text of the notification.
hasReply boolean A boolean property representing whether the notification has a reply action.
replyPlaceholder string A string property representing the reply placeholder of the notification.
silent boolean A boolean property representing whether the notification is silent.
sound string A string property representing the sound of the notification.
subtitle string A string property representing the subtitle of the notification.
timeoutType 'default' | 'never' A string property representing the type of timeout duration for the notification. Can be default or never.

If timeoutType is set to never, the notification never expires. It stays open until closed by the calling API or the user. linux and win32 only.
title string A string property representing the title of the notification.
toastXml string A string property representing the custom Toast XML of the notification. win32 only.
urgency 'critical' | 'low' | 'normal' A string property representing the urgency level of the notification. Can be normal, critical, or low.

Default is low. linux only.

Methods

Method Returns Description
addListener(event, listener) this Registers an event listener that is invoked when one of the notification's actions is activated.
addListener(event, listener) this Registers an event listener that is invoked when the notification is clicked by the user.
addListener(event, listener) this Registers an event listener that is invoked when the notification is closed by manual intervention from the user.
addListener(event, listener) this Registers an event listener that is invoked when an error is encountered while creating and showing the native notification. win32 only.
addListener(event, listener) this Registers an event listener that is invoked when the user clicks the "Reply" button on a notification with hasReply: true. darwin only.
addListener(event, listener) this Registers an event listener that is invoked when the notification is shown to the user.
close() void Dismisses the notification.
isSupported() boolean Whether or not desktop notifications are supported on the current system.
on('action', listener) this Registers an event listener that is invoked when one of the notification's actions is activated.
on('click', listener) this Registers an event listener that is invoked when the notification is clicked by the user.
on('close', listener) this Registers an event listener that is invoked when the notification is closed by manual intervention from the user.
on('failed', listener) this Registers an event listener that is invoked when an error is encountered while creating and showing the native notification. win32 only.
on('reply', listener) this Registers an event listener that is invoked when the user clicks the "Reply" button on a notification with hasReply: true. darwin only.
on('show', listener) this Registers an event listener that is invoked when the notification is shown to the user.
once(event, listener) this Registers a one-time event listener that is invoked when one of the notification's actions is activated.
once(event, listener) this Registers a one-time event listener that is invoked when the notification is clicked by the user.
once(event, listener) this Registers a one-time event listener that is invoked when the notification is closed by manual intervention from the user.
once(event, listener) this Registers a one-time event listener that is invoked when an error is encountered while creating and showing the native notification. win32 only.
once(event, listener) this Registers a one-time event listener that is invoked when the user clicks the "Reply" button on a notification with hasReply: true. darwin only.
once(event, listener) this Registers a one-time event listener that is invoked when the notification is shown to the user.
removeListener(event, listener) this Removes the event listener for one of the notification's actions being activated.
removeListener(event, listener) this Removes the event listener for the notification being clicked.
removeListener(event, listener) this Removes the event listener for the notification being closed.
removeListener(event, listener) this Removes the event listener for the notification failing to show.
removeListener(event, listener) this Removes the event listener for the notification's inline reply.
removeListener(event, listener) this Removes the event listener for the notification being shown.
show() void Immediately shows the notification to the user, please note this means unlike the HTML5 Notification implementation, instantiating a new Notification does not immediately show it to the user, you need to call this method before the OS will display it.

If the notification has been shown before, this method will dismiss the previously shown notification and create a new one with identical properties.

Links to this page: