A simple and opinionated library for working with OS notifications

Overview

desktop-notifications

A simple and opinionated library for working with OS notifications

Goals

  • zero dependencies
  • good support for Windows notifications
  • leverage TypeScript declarations wherever possible

Note: This is currently in preview, with support for features that GitHub Desktop.

Install

$ npm install --save desktop-notifications
# or
$ yarn add desktop-notifications

But Why?

The current set of options for interacting with notifications, especially on Windows, have some limitations that meant we couldn't use them easily in GitHub Desktop:

  • electron doesn't support Windows notifications when those are hidden away in the Action Center, because it doesn't have a COM activator that could leverage CLSID-based activation. More details about this can be found in electron/electron#29461.
  • node-notifier relies on snoretoast to handle notifications on Windows, and the way it's used is only able to detect one event with each notification, and also requires the app to use the same CLSID that is hardcoded in snoretoast.
  • electron-windows-notifications has many dependencies around NodeRT which, as of today, also require some manual steps in order to build them.

After exploring all these options, we decided to write our own library to do the stuff we require using no dependencies at all and having all the features we need.

Documentation

See the documentation under the docs folder.

Supported versions

Each release of desktop-notifications includes prebuilt binaries based on N-API, with support for different versions of Node and Electron. Please refer to the N-API version matrix and the release documentation for Node and Electron to see what is supported currently.

Contributing

Read the Setup section to ensure your development environment is setup for what you need.

This project isn't about implementing a 1-1 replication of any other notifications API, but implementing just enough for whatever usage GitHub Desktop needs.

If you want to see something supported, open an issue to start a discussion about it.

Issues
  • Memory usage improvements

    Memory usage improvements

    This PR makes a few changes around memory usage. But first, some context:

    • Windows doesn't have a specific event when a notification is completely dismissed vs when it's hidden away from the user into the Action Center, so we're forced to keep around the click/event callbacks for as long as we can.
    • In my initial implementation, the native side would store these callbacks for every notification.

    The changes made in this PR are:

    • Unifying all the events sent by the native side to only one callback that will receive both the event and the notificationID.
    • The JS side will manage the callbacks with the consumer app. The less we do on native side, the less we need to port to other platforms, if we ever do that ūüėĄ
    • On this JS side, we will use a LRU cache to keep the number of in-memory notifications/callbacks under control.
    opened by sergiou87 1
  • Bump ajv from 6.7.0 to 6.12.6

    Bump ajv from 6.7.0 to 6.12.6

    Bumps ajv from 6.7.0 to 6.12.6.

    Release notes

    Sourced from ajv's releases.

    v6.12.6

    Fix performance issue of "url" format.

    v6.12.5

    Fix uri scheme validation (@‚ÄčChALkeR). Fix boolean schemas with strictKeywords option (#1270)

    v6.12.4

    Fix: coercion of one-item arrays to scalar that should fail validation (failing example).

    v6.12.3

    Pass schema object to processCode function Option for strictNumbers (@‚Äčissacgerges, #1128) Fixed vulnerability related to untrusted schemas (CVE-2020-15366)

    v6.12.2

    Removed post-install script

    v6.12.1

    Docs and dependency updates

    v6.12.0

    Improved hostname validation (@‚Äčsambauers, #1143) Option keywords to add custom keywords (@‚Äčfranciscomorais, #1137) Types fixes (@‚Äčboenrobot, @‚ÄčMattiAstedrone) Docs:

    v6.11.0

    Time formats support two digit and colon-less variants of timezone offset (#1061 , @‚Äčcjpillsbury) Docs: RegExp related security considerations Tests: Disabled failing typescript test

    v6.10.2

    Fix: the unknown keywords were ignored with the option strictKeywords: true (instead of failing compilation) in some sub-schemas (e.g. anyOf), when the sub-schema didn't have known keywords.

    v6.10.1

    Fix types Fix addSchema (#1001) Update dependencies

    v6.10.0

    Option strictDefaults to report ignored defaults (#957, @‚Äčnot-an-aardvark) Option strictKeywords to report unknown keywords (#781)

    v6.9.0

    OpenAPI keyword nullable can be any boolean (and not only true). Custom keyword definition changes:

    • dependencies option in to require the presence of keywords in the same schema.

    ... (truncated)

    Commits
    • fe59143 6.12.6
    • d580d3e Merge pull request #1298 from ajv-validator/fix-url
    • fd36389 fix: regular expression for "url" format
    • 490e34c docs: link to v7-beta branch
    • 9cd93a1 docs: note about v7 in readme
    • 877d286 Merge pull request #1262 from b4h0-c4t/refactor-opt-object-type
    • f1c8e45 6.12.5
    • 764035e Merge branch 'ChALkeR-chalker/fix-comma'
    • 3798160 Merge branch 'chalker/fix-comma' of git://github.com/ChALkeR/ajv into ChALkeR...
    • a3c7eba Merge branch 'refactor-opt-object-type' of github.com:b4h0-c4t/ajv into refac...
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Load native module lazily

    Load native module lazily

    As suggested by @niik , this PR switches to a lazy load of the native module, to prevent it from crashing when the app starts, since those crashes are harder to trace. Instead, the native module will be loaded the first time it's needed (probably when initializeNofitications is invoked).

    opened by sergiou87 0
  • Check Windows version

    Check Windows version

    This PR checks the Windows version to conditionally require the native module (only W10 and newer supported), and also exports a supportsNotifications function for consumers of desktop-notifications.

    opened by sergiou87 0
  • Add more control over notifications

    Add more control over notifications

    This PR introduces more control over notifications:

    • Check whether or not the app has permission from the user to display notifications.
    • Request permission to the user to display notifications (macOS only).
    • Handle notifications from previous app sessions.

    The changes require to support all that on macOS require us to invoke all the notifications code from the main process on an Electron app. That's why this PR also replaces the previous sample script with an Electron sample app, because it eases testing for us in a more similar environment to the GitHub Desktop app.

    opened by sergiou87 0
Releases(v0.1.7)
Owner
GitHub Desktop
Simple collaboration from your desktop
GitHub Desktop
An un-opinionated url-based Router implementation (Navigator 2.0).

An un-opinionated url-based Router implementation (Navigator 2.0).

gskinner team 3 Feb 5, 2022
FSlateNotificationManager (Creating Custom Notifications in Unreal Engine)

FSlateNotificationManager (Creating Custom Notifications in Unreal Engine) An Example of creating custom notifications in Unreal Engine, similar to "L

Alessa 4 Nov 7, 2021
A single file, single function, header to make notifications on the PS4 easier

Notifi Synopsis Adds a single function notifi(). It functions like printf however the first arg is the image to use (NULL and any invalid input should

Al Azif 7 Mar 24, 2022
A run-time C++ library for working with units of measurement and conversions between them and with string representations of units and measurements

Units What's new Some of the CMake target names have changed in the latest release, please update builds appropriately Documentation A library that pr

Lawrence Livermore National Laboratory 96 May 10, 2022
Servo library with stm developed by the Liek Software Team. We are working on new versions.

Liek-Servo-Library Liek Servo Library is a library that makes it easy for you to drive servo motors with STM32F10x series cards. The library is still

null 14 Jan 13, 2022
a playground for working with fully static tensors and automatic differentiation

This is a playground for learning about how to apply template-meta-programming to get more efficient evaluation for tensor-based automatic differentiation.

Edward Kmett 16 Mar 18, 2021
A guide and set of tools for working with TinyML powered Audio Sensors

Audio Sensor Toolkit This is a guide on how to build an Audio Sensor using Machine Learning, and helpful tools. Audio Sensor Guide Audio Tools Acceler

IQT Labs 19 Sep 16, 2021
Best practices, conventions, and tricks for ROS. Do you want to become a robotics master? Then consider graduating or working at the Robotics Systems Lab at ETH in Z√ľrich!

ROS Best Practices, Conventions and Tricks Best practices for ROS2 in the making. See the Foxy branch in the meanwhile. This is a loose collection of

Robotic Systems Lab - Legged Robotics at ETH Z√ľrich 1.1k May 10, 2022
ūüĒć A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.

?? ImHex A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM. Supporting If you like my work, plea

WerWolv 12.7k May 15, 2022
Working example for local_flutter_notification package in Flutter. Includes setting notification at custom time, daily, weekly.

local_notification_example Working example for local_flutter_notification package in Flutter. Includes setting notification at custom time, daily, wee

Nivedita Datta 4 Oct 3, 2021
This project aims to bring back a productive working environment on Windows 11

This project aims to bring back a productive working environment on Windows 11

Valentin-Gabriel Radu 5.4k May 10, 2022
Create a working USB CDC class starting from the clear template provided by ST

STM32F3 USB Classes from template The goal of this project is to provide a decent collection of guidelines for creating working USB classes to be used

Michele Perrone 1 Oct 30, 2021
Kurarin - barely working osu! beatmap visualizer made in V

Kurarin - barely working osu! beatmap visualizer made in V About This is actually one of my first V project and I barely know anything about programmi

null 23 May 7, 2022
a unix inspired, non posix compliant micro kernel (more of a monolithic kernel for now though) that i am working on in my spare time

toy-kernel a unix inspired, non posix compliant micro kernel (more of a monolithic kernel for now though) that i am working on in my spare time prereq

czapek 14 May 2, 2022
Bond is a cross-platform framework for working with schematized data

Bond is a cross-platform framework for working with schematized data. It supports cross-language de/serialization and powerful generic mechanisms for efficiently manipulating data. Bond is broadly used at Microsoft in high scale services.

Microsoft 2.4k May 9, 2022
This project contains three scripts to help working with the steam-runtime, especially outside of Steam.

This project contains three scripts to help working with the steam-runtime, especially outside of Steam. See these blog posts for more details: steam-

J√łrgen P. Tjern√ł 11 Oct 22, 2021
A (sub) C compiler working in progress.

acc A zero-dependence (sub) C compiler working in progress written in pure ISO C. Build from source Make sure you have gcc and cmake on your PATH. If

null 3 Apr 16, 2022
SSD1306 library and simple graphics core library based on Adafruit GFX Library.

Raspberry Pico SSD1306 + GFX Library Based on Adafruit GFX Library https://github.com/adafruit/Adafruit-GFX-Library Usage Hardware Connect your SSD130

Marcin Bober 26 Apr 28, 2022
A simple implementation of a parser and its use to calculate simple mathematical expressions

Calculator C Parser A simple implementation of a parser and its use to calculate simple mathematical expressions I haven't written a detailed descript

Romes 14 Nov 8, 2021