new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Electron · API · all subjects

notification/methods

16 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Notification.isSupported() static method

Notification.isSupported() returns a boolean indicating whether desktop notifications are supported on the current system.

Notification.handleActivation() static method Windows

Notification.handleActivation(callback) is a Windows-only static method that registers a callback to handle all notification activations. The callback receives a details object of type ActivationArguments containing information about notification clicks, replies, and action button presses. It handles timing automatically: if an activation already occurred before calling this method, the callback is invoked immediately; for subsequent activations, it is invoked when they occur. The callback remains registered until replaced by another call to handleActivation(). This method provides a centralized way to handle notification interactions in all scenarios including cold start, persisted notifications after restart, garbage-collected notification objects, and in-memory notification objects.

Notification.getHistory() static method macOS

Notification.getHistory() is a macOS-only static method that returns Promise<Notification[]> resolving with an array of Notification objects representing all delivered notifications still present in Notification Center. Each returned Notification is a live object connected to the corresponding delivered notification. Interaction events (click, reply, action, close) will fire on these objects when the user interacts with the notification in Notification Center. This is useful after an app restart to re-attach event handlers to notifications from a previous session. The returned notifications have id, groupId, title, subtitle, and body properties populated from Notification Center information. Other properties like actions, silent, and icon are not available from delivered notifications and will have default values. This method requires the application to be code-signed; unsigned development builds will resolve with an empty array. Unlike notifications created with new Notification(), notifications returned by getHistory() remain visible in Notification Center when garbage collected. Calling show() on a restored notification removes the original from Notification Center and posts a new one with the same properties.

Notification.remove() static method macOS

Notification.remove(id) is a macOS-only static method that removes one or more delivered notifications from Notification Center by their identifier(s). The id parameter is string | string[] and corresponds to the id values set in the Notification constructor.

Notification.removeAll() static method macOS

Notification.removeAll() is a macOS-only static method that removes all of the app's delivered notifications from Notification Center.

Notification.removeGroup() static method macOS

Notification.removeGroup(groupId) is a macOS-only static method that removes all delivered notifications with the given groupId from Notification Center. The groupId parameter is a string that corresponds to the groupId value set in the Notification constructor.

Notification constructor options

new Notification([options]) creates a notification with the following optional properties: id (string, macOS Windows, maps to UNNotificationRequest identifier on macOS and toast Tag on Windows, defaults to random UUID), groupId (string, macOS Windows, maps to UNNotificationContent threadIdentifier on macOS and toast Group on Windows), groupTitle (string, Windows only, title for notification group header), title (string, displayed at top of notification), subtitle (string, macOS only, displayed below title), body (string, displayed below title or subtitle), silent (boolean, suppresses OS notification noise), icon (string | NativeImage, must be valid path if string), hasReply (boolean, macOS Windows, adds inline reply option), timeoutType (string, Linux Windows, 'default' or 'never'), replyPlaceholder (string, macOS Windows, placeholder text for inline reply field), sound (string, macOS only, name of sound file to play), urgency (string, Linux Windows, 'normal', 'critical', or 'low'), actions (NotificationAction[], macOS Windows, actions to add to notification), closeButtonText (string, macOS only, custom close button title), toastXml (string, Windows only, custom Toast XML superseding other properties).

notification.show() instance method

notification.show() immediately shows the notification to the user. Unlike the web notification API, instantiating new Notification() does not immediately show it; you must call show(). If the notification has been shown before, this method dismisses the previously shown notification and creates a new one with identical properties. On macOS, calling show() on a notification returned by Notification.getHistory() removes the original notification from Notification Center and posts a new one with the same properties.

notification.close() instance method

notification.close() dismisses the notification. On Windows, calling notification.close() while the notification is visible on screen will dismiss the notification and remove it from the Action Center. If notification.close() is called after the notification is no longer visible on screen, it will try to remove it from the Action Center.

Notification.handleActivation() example

const { Notification, app } = require('electron') app.whenReady().then(() => { // Register handler for all notification activations Notification.handleActivation((details) => { console.log('Notification activated:', details.type) if (details.type === 'reply') { console.log('User reply:', details.reply) } else if (details.type === 'action') { console.log('Action index:', details.actionIndex) } }) }) This example shows how to register a callback to handle all notification activations including replies and action button presses.

Notification.getHistory() example

const { Notification, app } = require('electron') app.whenReady().then(async () => { // Restore notifications from a previous session const notifications = await Notification.getHistory() for (const n of notifications) { console.log(`Found delivered notification: ${n.id} - ${n.title}`) n.on('click', () => { console.log(`User clicked: ${n.id}`) }) n.on('reply', (event) => { console.log(`User replied to ${n.id}: ${event.reply}`) }) } // Keep references so events continue to fire }) This example shows how to restore notifications from a previous session and re-attach event handlers to them.

Notification.remove() example

const { Notification } = require('electron') // Remove a single notification Notification.remove('my-notification-id') // Remove multiple notifications Notification.remove(['msg-1', 'msg-2', 'msg-3']) This example shows how to remove single or multiple notifications by their identifiers.

Notification.removeAll() example

const { Notification } = require('electron') Notification.removeAll() This example shows how to remove all of the app's delivered notifications.

Notification.removeGroup() example

const { Notification } = require('electron') // Remove all notifications in the 'chat-thread-1' group Notification.removeGroup('chat-thread-1') This example shows how to remove all delivered notifications with a specific group identifier.

notification.show() example

const { Notification, app } = require('electron') app.whenReady().then(() => { const n = new Notification({ title: 'Title!', subtitle: 'Subtitle!', body: 'Body!' }) n.show() }) This example shows how to create and display a notification.

notification.close() example

const { Notification, app } = require('electron') app.whenReady().then(() => { const n = new Notification({ title: 'Title!', subtitle: 'Subtitle!', body: 'Body!' }) n.show() setTimeout(() => n.close(), 5000) }) This example shows how to create a notification, display it, and close it after 5 seconds.

Give your agent this brain