Giter VIP home page Giter VIP logo

electron-notifications's Introduction

Electron Notifications

A node module for sending notifications in electron applications.

screenshot

Quick Usage

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'],
})

Installation

npm install --save electron-notifications

Introduction

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.

Options

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.

Events

In addition to the events provided by electron you also have access to the following 3 additional events.

Clicked

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()
})

Swiped Right

When the notification has been swiped to the right. This usually indiciated the user wants to dismiss the notification.

const notification = notifier.notify('Calendar')

notification.on('swipedRight', () => {
  notification.close()
})

Button Clicked

When any one of the buttons are clicked, it'll trigger a buttonClicked event, and pass the text that was clicked to the handler.

const notification = notifier.notify('Calendar', {
  buttons: ['Dismiss', 'Snooze'],
})

notification.on('buttonClicked', (text) => {
  if (text === 'Snooze') {
    // Snooze!
  }
  notification.close()
})

electron-notifications's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.