Giter VIP home page Giter VIP logo

angular-web-notification's Introduction

angular-web-notification

Bower Version NPM Version Build Status Coverage Status bitHound Code Inline docs
License Known Vulnerabilities Retire Status

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);
                }
            });
        });
    }
};
}]);

Installation

Run bower install in your project as follows:

bower install angular-web-notification --save

Or if you are using NPM to download client libraries, you can install it as follows:

npm install --save angular-web-notification

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
2017-05-01 v1.2.22 Maintenance
2017-01-22 v1.2.0 Split the internal web notification API into a new project: simple-web-notification
2017-01-13 v1.0.26 Maintenance
2016-11-23 v1.0.19 Use forked version of html5-desktop-notifications in order to resolve few issues
2016-11-19 v1.0.18 Maintenance
2016-11-04 v1.0.16 Upgrading to html5-desktop-notifications 3.0.0
2016-10-16 v1.0.15 Maintenance
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-09-07 v1.0.3 Maintenance
2016-06-14 v0.0.78 Published via NPM (in addition to bower)
2016-06-14 v0.0.77 Maintenance
2016-03-08 v0.0.65 Added webNotification.permissionGranted attribute
2016-02-24 v0.0.64 Maintenance
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-09-02 v0.0.29 Maintenance
2015-08-16 v0.0.22 uglify fix
2015-08-02 v0.0.21 Maintenance
2015-02-16 v0.0.7 Automatic unit tests via karma
2015-02-05 v0.0.5 Doc changes
2014-12-30 v0.0.4 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.