### Install electron-notifications Source: https://github.com/bayleedev/electron-notifications/blob/master/readme.md Provides the npm command to install the `electron-notifications` package as a project dependency. ```shell npm install --save electron-notifications ``` -------------------------------- ### Run Playbook for Live Examples Source: https://github.com/bayleedev/electron-notifications/blob/master/readme.md Instructions to clone the repository and run the playbook to see live examples of the notification module in action and edit code in place. ```shell git clone git@github.com:blainesch/electron-notifications.git npm run playbook ``` -------------------------------- ### Simple Notification - electron-notifications (JavaScript) Source: https://github.com/bayleedev/electron-notifications/blob/master/playbook/playbook.html Demonstrates the most basic usage of the electron-notifications library to display a simple notification. This requires the 'electron-notifications' package to be installed. It shows how to trigger a notification with a title. ```javascript const notifier = require('electron-notifications') notifier.notify('Calendar') ``` -------------------------------- ### Click Event Handling - electron-notifications (JavaScript) Source: https://github.com/bayleedev/electron-notifications/blob/master/playbook/playbook.html Provides an example of how to handle the 'clicked' event emitted by a notification. When the notification itself is clicked, a callback function is executed, which in this case closes the notification and shows an alert. Requires 'electron-notifications'. ```javascript const notifier = require('electron-notifications') const notification = notifier.notify('Calendar') notification.on('clicked', () => { notification.close() alert('I was clicked!') }) ``` -------------------------------- ### Vertical Buttons Notification - electron-notifications (JavaScript) Source: https://github.com/bayleedev/electron-notifications/blob/master/playbook/playbook.html Demonstrates how to display notification buttons in a vertical layout using the 'vertical: true' option. This example requires the 'electron-notifications' package and shows customization of the button presentation. ```javascript const notifier = require('electron-notifications') notifier.notify('Calendar', { message: 'Event begins in 10 minutes', icon: 'http://cl.ly/J49B/3951818241085781941.png', buttons: ['Dismiss', 'Snooze'], vertical: true, }) ``` -------------------------------- ### Full Options Notification - electron-notifications (JavaScript) Source: https://github.com/bayleedev/electron-notifications/blob/master/playbook/playbook.html Illustrates how to use the electron-notifications library with a full set of options for customization. This includes setting a message, an icon, custom buttons, and a duration for the notification. Dependencies include the 'electron-notifications' package. ```javascript const notifier = require('electron-notifications') notifier.notify('Calendar', { message: 'Event begins in 10 minutes', icon: 'http://cl.ly/J49B/3951818241085781941.png', buttons: ['Dismiss', 'Snooze'], duration : 60000 }) ``` -------------------------------- ### Stacking Notifications - electron-notifications (JavaScript) Source: https://github.com/bayleedev/electron-notifications/blob/master/playbook/playbook.html Shows how to implement stacking for notifications, where a placeholder like '{i}' in the title is replaced by the notification count. This feature helps manage multiple notifications efficiently. Requires the 'electron-notifications' package. ```javascript const notifier = require('electron-notifications') notifier.notify('Calendar {i}', { message: 'Event begins in 10 minutes', icon: 'http://cl.ly/J49B/3951818241085781941.png', buttons: ['Dismiss', 'Snooze'], duration : 10000 }) ``` -------------------------------- ### Send Basic and Advanced Notifications Source: https://github.com/bayleedev/electron-notifications/blob/master/readme.md Demonstrates how to send notifications using the `electron-notifications` module. It covers sending a notification with just a title and a more advanced usage with options like message, icon, and buttons. ```javascript const notifier = require('electron-notifications') // Just title notifier.notify('Calendar') // Full Options notifier.notify('Calendar', { message: 'Event begins in 10 minutes', icon: 'http://cl.ly/J49B/3951818241085781941.png', buttons: ['Dismiss', 'Snooze'], }) ``` -------------------------------- ### Button Click Handling - electron-notifications (JavaScript) Source: https://github.com/bayleedev/electron-notifications/blob/master/playbook/playbook.html Demonstrates how to handle clicks on notification buttons. The 'buttonClicked' event provides the text and index of the clicked button, allowing for specific actions based on user selection. Requires the 'electron-notifications' package. ```javascript const notifier = require('electron-notifications') const notification = notifier.notify('Calendar', { buttons: ['Dismiss', 'Snooze'], }) notification.on('buttonClicked', (text, index) => { notification.close() alert('You clicked "' + text + '" at index ' + index) }) ``` -------------------------------- ### Swipe Right Event Handling - electron-notifications (JavaScript) Source: https://github.com/bayleedev/electron-notifications/blob/master/playbook/playbook.html Shows how to capture and respond to a 'swipedRight' event from a notification. This allows for custom actions when a user performs a swipe gesture on the notification. The 'electron-notifications' package is a prerequisite. ```javascript const notifier = require('electron-notifications') const notification = notifier.notify('Calendar') notification.on('swipedRight', () => { notification.close() alert('I was swiped!') }) ``` -------------------------------- ### Handle Notification Click Event Source: https://github.com/bayleedev/electron-notifications/blob/master/readme.md Shows how to attach an event listener to a notification object to handle clicks. When clicked, the notification is closed. ```javascript const notification = notifier.notify('Calendar') notification.on('clicked', () => { notification.close() }) ``` -------------------------------- ### Handle Button Click Event Source: https://github.com/bayleedev/electron-notifications/blob/master/readme.md Illustrates how to handle the 'buttonClicked' event, which fires when a user clicks one of the notification's buttons. It provides the button text, index, and original options to the handler, allowing for custom actions like snoozing or opening a URL. ```javascript const notification = notifier.notify('Calendar', { buttons: ['Dismiss', 'Snooze'], url: "http://google.com" }) notification.on('buttonClicked', (text, buttonIndex, options) => { if (text === 'Snooze') { // Snooze! } else if(buttonIndex === 1) { //open options.url } notification.close() }) ``` -------------------------------- ### Handle Swiped Right Event Source: https://github.com/bayleedev/electron-notifications/blob/master/readme.md Demonstrates handling the 'swipedRight' event on a notification, which typically signifies user intent to dismiss the notification. The notification is closed upon receiving this event. ```javascript const notification = notifier.notify('Calendar') notification.on('swipedRight', () => { notification.close() }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.