'use strict';

/**
 * Desktop notifications
 * see http://caniuse.com/#search=notifications
 *
 * If the browser does not support notifications, the message will
 * be logged to the browser console
 */
app.factory('AvvisoService', [

    function() {
        var hasNotifications = window.Notification != undefined;

        if (hasNotifications) {
            Notification.requestPermission();
        }

        var Service = {
            notify: function(title, body) {
                if (hasNotifications) {
                    var notif = new Notification(title, {
                        body: body,
                        // icon: // TODO: add purkinje icon (only displayed in Firefox; not Chrome)
                    });
                } else {
                    console.debug(title + ': ' + body);
                }
            }
        };

        return Service;
    }
]);

'use strict';

/**
 * Desktop notifications
 * see http://caniuse.com/#search=notifications
 *
 * If the browser does not support notifications, the message will
 * be logged to the browser console
 */
app.factory('AvvisoService', ['$window',

    function($window) {
        var hasNotifications = $window.Notification != undefined;

        if (hasNotifications) {
            Notification.requestPermission();
        }

        var Service = {
            notify: function(title, body) {
                if (hasNotifications) {
                    var notif = new Notification(title, {
                        body: body,
                        // icon: // TODO: add purkinje icon (only displayed in Firefox; not Chrome)
                    });
                } else {
                    console.debug(title + ': ' + body);
                }
            }
        };

        return Service;
    }
]);

Use $window service instead of global window object (best practice)
Use $window service instead of global window object (best practice)
