All Projects → sagiegurari → Angular Web Notification

sagiegurari / Angular Web Notification

Licence: apache-2.0
Web Notifications AngularJS Service

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Angular Web Notification

Monocle
PoGo mapper and notifier
Stars: ✭ 122 (-31.46%)
Mutual labels:  notification
Pushnotifications
🐉 A macOS, Linux, Windows app to test push notifications on iOS and Android
Stars: ✭ 1,813 (+918.54%)
Mutual labels:  notification
Notifme Sdk
A Node.js library to send all kinds of transactional notifications.
Stars: ✭ 1,854 (+941.57%)
Mutual labels:  notification
React Native Alarm Notification
schedule alarm and local notification in react-native
Stars: ✭ 122 (-31.46%)
Mutual labels:  notification
Vue Toastify
🔥 Simple, extendable, dependency free notification plugin. 🔥
Stars: ✭ 126 (-29.21%)
Mutual labels:  notification
Go Fcm
Firebase Cloud Messaging Library for Golang
Stars: ✭ 138 (-22.47%)
Mutual labels:  notification
Pwa Cookbook
personally website
Stars: ✭ 107 (-39.89%)
Mutual labels:  notification
Vue Toasted
🖖 Responsive Touch Compatible Toast plugin for VueJS 2+
Stars: ✭ 2,091 (+1074.72%)
Mutual labels:  notification
Nativescript Feedback
📢 Non-blocking textual feedback for your NativeScript app
Stars: ✭ 127 (-28.65%)
Mutual labels:  notification
Firupdater
Fir.im通道APK更新器,使用简单,让自己的demo快速具备升级功能
Stars: ✭ 148 (-16.85%)
Mutual labels:  notification
React Native Dropdownalert
A simple alert to notify users about new chat messages, something went wrong or everything is ok.
Stars: ✭ 1,628 (+814.61%)
Mutual labels:  notification
Sounds Webpack Plugin
🔊Notify or errors, warnings, etc with sounds
Stars: ✭ 125 (-29.78%)
Mutual labels:  notification
Follow Github Organisation
Get notified when a new repository is created in a GitHub organisation
Stars: ✭ 143 (-19.66%)
Mutual labels:  notification
Icinga2
Icinga is a monitoring system which checks the availability of your network resources, notifies users of outages, and generates performance data for reporting.
Stars: ✭ 1,670 (+838.2%)
Mutual labels:  notification
Notifyjs
Notify.js - A simple, versatile notification library
Stars: ✭ 1,844 (+935.96%)
Mutual labels:  notification
Qmlnotify
Awesome notification server in QML
Stars: ✭ 114 (-35.96%)
Mutual labels:  notification
Noty
A simple library for creating animated warnings/dialogs/alerts for Android.
Stars: ✭ 136 (-23.6%)
Mutual labels:  notification
Notiflix
Notiflix is a JavaScript library for client-side non-blocking notifications, popup boxes, loading indicators, and more that makes your web projects much better.
Stars: ✭ 172 (-3.37%)
Mutual labels:  notification
Time To Leave
Log work hours and get notified when it's time to leave the office and start to live.
Stars: ✭ 155 (-12.92%)
Mutual labels:  notification
Update Check
Minimalistic update notifications for command line interfaces
Stars: ✭ 145 (-18.54%)
Mutual labels:  notification

angular-web-notification

NPM Version CI Coverage Status Known Vulnerabilities Inline docs License

Web Notifications AngularJS Service

Overview

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.

Demo

Live Demo

Usage

In order to use the angular service you first must add the relevant dependencies:

<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="simple-web-notification/web-notification.js"></script>
<script type="text/javascript" src="angular-web-notification.js"></script>

Next you must define it as a dependency in your main angular module as follows:

angular.module('exampleApp', [
    'angular-web-notification'
]);

Now you can inject and use the service into your modules (directives/services/...), for example:

angular.module('exampleApp').directive('showButton', ['webNotification', function (webNotification) {
return {
    ...
    link: function (scope, element) {
        element.on('click', function onClick() {
            webNotification.showNotification('Example Notification', {
                body: 'Notification Text...',
                icon: 'my-icon.ico',
                onClick: function onNotificationClicked() {
                    console.log('Notification clicked.');
                },
                autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function)
            }, function onShow(error, hide) {
                if (error) {
                    window.alert('Unable to show notification: ' + error.message);
                } else {
                    console.log('Notification Shown.');

                    setTimeout(function hideNotification() {
                        console.log('Hiding notification....');
                        hide(); //manually close the notification (you can skip this if you use the autoClose option)
                    }, 5000);
                }
            });
        });
    }
};
}]);

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;
navigator.serviceWorker.register('service-worker.js').then(function(registration) {
    serviceWorkerRegistration = registration;
});

//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.on('click', function onClick() {
    webNotification.showNotification('Example Notification', {
        serviceWorkerRegistration: serviceWorkerRegistration,
        body: 'Notification Text...',
        icon: 'my-icon.ico',
        actions: [
            {
                action: 'Start',
                title: 'Start'
            },
            {
                action: 'Stop',
                title: 'Stop'
            }
        ],
        autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function)
    }, function onShow(error, hide) {
        if (error) {
            window.alert('Unable to show notification: ' + error.message);
        } else {
            console.log('Notification Shown.');

            setTimeout(function hideNotification() {
                console.log('Hiding notification....');
                hide(); //manually close the notification (you can skip this if you use the autoClose option)
            }, 5000);
        }
    });
});

Installation

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

Limitations

The web notifications API is not fully supported in all browsers.

Please see supported browser versions for more information on the official spec support.

API Documentation

See full docs at: API Docs

Contributing

See contributing guide

Release History

Date Version Description
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
2019-02-08 v1.2.31 Maintenance
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-08-16 v0.0.22 uglify fix
2015-02-16 v0.0.7 Automatic unit tests via karma
2015-02-05 v0.0.5 Doc changes
2014-12-09 v0.0.3 API now enables/disables the capability to automatically request for permissions needed to display the notification.
2014-12-08 v0.0.2 Initial release

License

Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].