Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
electron-notifications
Advanced tools
Readme
A node module for sending notifications in electron applications.
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'],
})
npm install --save electron-notifications
If you'd like to see this in action you can run the playbook and try out live examples and edit the code in place.
git clone git@github.com:blainesch/electron-notifications.git
npm run playbook
When you create a new notification, your notification is queued, since we only display one at a time. Each notification is a BrowserWindow instance, so it's completely cross platform.
All options are optional.
message
: A message to display under the title.icon
: The absolute URL of a icon displayed to the left of the text.buttons
: One or two buttons to display on the right of the notification.vertical
: Boolean (default: false) that specifies that the buttons should be stacked vertically.duration
: Integer duration in milliseconds (default: 4000) to show the notification.flat
: Boolean (default: false) that specifies to use a flat button style notification.In addition to the events provided by electron you also have access to the following 3 additional events.
When the notification was clicked, but not dragged. This usually does the default action, or closes the notification.
const notification = notifier.notify('Calendar')
notification.on('clicked', () => {
notification.close()
})
When the notification has been swiped to the right. This usually indicates that the user wants to dismiss the notification.
const notification = notifier.notify('Calendar')
notification.on('swipedRight', () => {
notification.close()
})
When any one of the buttons are clicked, it'll trigger a buttonClicked
event,
and pass the text, button index and options to the handler.
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()
})
FAQs
A node module for sending notifications in electron applications
The npm package electron-notifications receives a total of 84 weekly downloads. As such, electron-notifications popularity was classified as not popular.
We found that electron-notifications demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.