Web Notifications AngularJS Service
The angular-web-notification is an angular service wrapper for the web notifications API.
It is using the simple-web-notification library which provides a simple and easy notification API which works across browsers and provides automatic permission handling.
See W3 Specification and simple-web-notification for more information.
Angular 2 and Up
For angular 2 and above, it is recommanded to use the simple-web-notification library directly.
It provides the same API and it is not dependend on angular.
In order to use the angular service you first must add the relevant dependencies:
Next you must define it as a dependency in your main angular module as follows:
Now you can inject and use the service into your modules (directives/services/...), for example:
In case you wish to use service worker web notifications, you must provide the serviceWorkerRegistration in the options as follows:
//Get the service worker registeration object at the startup of the application.//This is an aysnc operation so you should not try to use it before the promise is finished.var serviceWorkerRegistration;navigatorserviceWorker;//when setting on even handlers in different areas of the application, use that registration object instance (must be done after the registration is available)element;
Run npm install in your project as follows:
npm install --save angular-web-notification
Or if you are using bower, you can install it as follows:
bower install angular-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|
|2017-08-25||v1.2.24||Document support of service worker web notifications|
|2017-01-22||v1.2.0||Split the internal web notification API into a new project: simple-web-notification|
|2016-11-23||v1.0.19||Use forked version of html5-desktop-notifications in order to resolve few issues|
|2016-11-04||v1.0.16||Upgrading to html5-desktop-notifications 3.0.0|
|2016-09-10||v1.0.6||Default to website favicon.ico if icon not provided in options|
|2016-09-07||v1.0.4||Callback is now optional|
|2016-06-14||v0.0.78||Published via NPM (in addition to bower)|
|2016-03-08||v0.0.65||Added webNotification.permissionGranted attribute|
|2015-09-26||v0.0.31||Update bower dependencies|
|2015-09-26||v0.0.30||Added 'onClick' option to enable adding onclick event handler for the notification|
|2015-02-16||v0.0.7||Automatic unit tests via karma|
|2014-12-09||v0.0.3||API now enables/disables the capability to automatically request for permissions needed to display the notification.|
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.