Skip to content

ElectronNotification

Unofficial

Electron Notification for creating and showing native OS notifications.

Import:

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

Signature:

export class ElectronNotification

Properties

PropertyTypeDescription
actionsElectronNotificationAction[]A NotificationAction[] property representing the actions of the notification.
bodystringA string property representing the body of the notification.
closeButtonTextstringA string property representing the close button text of the notification.
hasReplybooleanA boolean property representing whether the notification has a reply action.
replyPlaceholderstringA string property representing the reply placeholder of the notification.
silentbooleanA boolean property representing whether the notification is silent.
soundstringA string property representing the sound of the notification.
subtitlestringA 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.
titlestringA string property representing the title of the notification.
toastXmlstringA 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

MethodReturnsDescription
addListener(event, listener)thisRegisters an event listener that is invoked when one of the notification's actions is activated.
addListener(event, listener)thisRegisters an event listener that is invoked when the notification is clicked by the user.
addListener(event, listener)thisRegisters an event listener that is invoked when the notification is closed by manual intervention from the user.
addListener(event, listener)thisRegisters an event listener that is invoked when an error is encountered while creating and showing the native notification. win32 only.
addListener(event, listener)thisRegisters an event listener that is invoked when the user clicks the "Reply" button on a notification with hasReply: true. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when the notification is shown to the user.
close()voidDismisses the notification.
isSupported()booleanWhether or not desktop notifications are supported on the current system.
on('action', listener)thisRegisters an event listener that is invoked when one of the notification's actions is activated.
on('click', listener)thisRegisters an event listener that is invoked when the notification is clicked by the user.
on('close', listener)thisRegisters an event listener that is invoked when the notification is closed by manual intervention from the user.
on('failed', listener)thisRegisters an event listener that is invoked when an error is encountered while creating and showing the native notification. win32 only.
on('reply', listener)thisRegisters an event listener that is invoked when the user clicks the "Reply" button on a notification with hasReply: true. darwin only.
on('show', listener)thisRegisters an event listener that is invoked when the notification is shown to the user.
once(event, listener)thisRegisters a one-time event listener that is invoked when one of the notification's actions is activated.
once(event, listener)thisRegisters a one-time event listener that is invoked when the notification is clicked by the user.
once(event, listener)thisRegisters a one-time event listener that is invoked when the notification is closed by manual intervention from the user.
once(event, listener)thisRegisters 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)thisRegisters 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)thisRegisters a one-time event listener that is invoked when the notification is shown to the user.
removeListener(event, listener)thisRemoves the event listener for one of the notification's actions being activated.
removeListener(event, listener)thisRemoves the event listener for the notification being clicked.
removeListener(event, listener)thisRemoves the event listener for the notification being closed.
removeListener(event, listener)thisRemoves the event listener for the notification failing to show.
removeListener(event, listener)thisRemoves the event listener for the notification's inline reply.
removeListener(event, listener)thisRemoves the event listener for the notification being shown.
show()voidImmediately 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: