Web Notifications made easy
The simple-web-notification is a simplified web notifications API with automatic permissions support.
This library requires no external dependencies, however the browser must support the Notification API or have a polyfill available.
See W3 Specification for more information.
In order to use the simplified web notification API you first must add the relevant dependencies:
Now you can use the API anywhere in your application, for example:
In case you wish to use service worker web notifications, you must provide the serviceWorkerRegistration in the options as follows:
In case you wish to invoke the permissions API manually you can use the webNotification.requestPermission function.
This function triggers the request permissions dialog in case permissions were not already granted.
//manually ask for notification permissions (invoked automatically if needed and allowRequest=true)webNotification;
When using an AMD loader (such as RequireJS) or CommonJS type loader, the webNotification object is not automatically defined on the window scope.
Run npm install in your project as follows:
npm install --save simple-web-notification
Or if you are using bower, you can install it as follows:
bower install simple-web-notification --save
The web notifications API is not fully supported in all browsers.
Please see supported browser versions for more information on the official spec support.
See full docs at: API Docs
|2020-05-13||v2.0.1||Revert bower.json deletion but not use it in CI build|
|2020-05-11||v2.0.0||Migrate to github actions, upgrade minimal node version and remove bower|
|2018-06-25||v1.0.28||Expose webNotification.requestPermission #5|
|2018-06-14||v1.0.26||Better error detection on chrome mobile #4|
|2017-08-25||v1.0.21||Support service worker web notifications|
|2017-01-31||v1.0.3||Removed polyfill dependency|
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.