• This repository has been archived on 06/Dec/2019
  • Stars
    star
    133
  • Rank 271,777 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

💥 A node module for sending notifications in electron applications.

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

Playbook

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 [email protected]:blainesch/electron-notifications.git
npm run playbook

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.
  • 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.

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 indicates that 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, 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()
})

More Repositories

1

alfred-chrome-bookmarks

🔖 Fast Chrome bookmark searcher for Alfred.
PHP
192
star
2

pry.js

🔬 A REPL for Node.
CoffeeScript
160
star
3

promise-princess

🐶 Learn JS Promises, with your friend 👑 Princess!
JavaScript
12
star
4

prettyArray

🌷 OO Arrays in PHP.
PHP
10
star
5

imageColor

🎨 Find primary color information.
PHP
8
star
6

li3_fake_model

👠 Alternative model library for lithium.
PHP
6
star
7

zazu-weather

Get weather information in zazu
JavaScript
6
star
8

alfred-ascii-search

Search ASCII characters by name or number.
Ruby
5
star
9

promise.arrg

JavaScript
4
star
10

li3_unit

Adds more assertion methods, and helps test controllers, models, and helpers.
PHP
4
star
11

alfred-find-replace

A workflow to find and replace on your last copied item.
Ruby
4
star
12

laravel-pretty-controller

Content negotiation for laravel!
PHP
2
star
13

li3_memoize

Will aid in the caching of expensive helper/model instance methods.
PHP
2
star
14

connect-four

🎲 Connect four on the command line.
Ruby
2
star
15

li3_leaderboard

A leaderboard to show off which developers are creating unit tests
PHP
2
star
16

li3_geocoder

Lithium data source for use with "willdurand/geocoder".
PHP
2
star
17

dotties

Baylee's local dotfiles.
Vim Script
2
star
18

zazu-pibble

Get moar pibbles
JavaScript
2
star
19

magicOracle

A proxy class developed for unit testing that makes all methods and properties public to you.
PHP
1
star
20

anon-o-gist

JavaScript
1
star
21

ocd

Static Code Analyzer for Ruby
Ruby
1
star
22

frak-cli

Command line interface for Frak
Clojure
1
star
23

baser

Word base helper proof of concept.
CoffeeScript
1
star
24

pry-example

A walkthrough of the pry.js node repl/debugger.
CoffeeScript
1
star
25

zazu-js-beautify

Beautify the JavaScript in your clipboard with Zazu!
JavaScript
1
star
26

async-numbers

JavaScript
1
star
27

terminal-profile-manager

💻 Automate your terminal profile/color scheme.
Ruby
1
star
28

pretty-profanity.rb

Cleans up profanity in text.
Ruby
1
star