function (title, options, callback) {
        var autoClose = 0;
        if (options.autoClose && (typeof options.autoClose === 'number')) {
            autoClose = options.autoClose;
        }

        //defaults the notification icon to the website favicon.ico
        if (!options.icon) {
            options.icon = '/favicon.ico';
        }

        var onNotification = function (notification) {
            //add onclick handler
            if (options.onClick && notification) {
                notification.onclick = options.onClick;
            }

            var hideNotification = function () {
                notification.close();
            };

            if (autoClose) {
                setTimeout(hideNotification, autoClose);
            }

            callback(null, hideNotification);
        };

        var serviceWorkerRegistration = options.serviceWorkerRegistration;
        if (serviceWorkerRegistration) {
            delete options.serviceWorkerRegistration;

            if (!options.tag) {
                tagCounter++;
                options.tag = 'webnotification-' + Date.now() + '-' + tagCounter;
            }
            var tag = options.tag;

            serviceWorkerRegistration.showNotification(title, options).then(function onCreate() {
                serviceWorkerRegistration.getNotifications({
                    tag: tag
                }).then(function notificationsFetched(notifications) {
                    if (notifications && notifications.length) {
                        onNotification(notifications[0]);
                    } else {
                        callback(new Error('Unable to find notification.'));
                    }
                }).catch(callback);
            }).catch(callback);
        } else {
            var instance;
            try {
                instance = new NotificationAPI(title, options);
            } catch (error) {
                callback(error);
            }

            //in case of no errors
            if (instance) {
                onNotification(instance);
            }
        }
    }
function (title, options, callback) {
        var autoClose = 0;
        if (options.autoClose && (typeof options.autoClose === 'number')) {
            autoClose = options.autoClose;
        }

        
        if (!options.icon) {
            options.icon = '/favicon.ico';
        }

        var onNotification = function (notification) {
            
            if (options.onClick && notification) {
                notification.onclick = options.onClick;
            }

            var hideNotification = function () {
                notification.close();
            };

            if (autoClose) {
                setTimeout(hideNotification, autoClose);
            }

            callback(null, hideNotification);
        };

        var serviceWorkerRegistration = options.serviceWorkerRegistration;
        if (serviceWorkerRegistration) {
            delete options.serviceWorkerRegistration;

            if (!options.tag) {
                tagCounter++;
                options.tag = 'webnotification-' + Date.now() + '-' + tagCounter;
            }
            var tag = options.tag;

            serviceWorkerRegistration.showNotification(title, options).then(function onCreate() {
                serviceWorkerRegistration.getNotifications({
                    tag: tag
                }).then(function notificationsFetched(notifications) {
                    if (notifications && notifications.length) {
                        onNotification(notifications[0]);
                    } else {
                        callback(new Error('Unable to find notification.'));
                    }
                }).catch(callback);
            }).catch(callback);
        } else {
            var instance;
            try {
                instance = new NotificationAPI(title, options);
            } catch (error) {
                callback(error);
            }

            
            if (instance) {
                onNotification(instance);
            }
        }
    }
function ( title , options , callback ) { var autoClose = 0 ; if ( options . autoClose && ( typeof options . autoClose === 'number' ) ) { autoClose = options . autoClose ; } //defaults the notification icon to the website favicon.ico if ( ! options . icon ) { options . icon = '/favicon.ico' ; } var onNotification = function ( notification ) { //add onclick handler if ( options . onClick && notification ) { notification . onclick = options . onClick ; } var hideNotification = function ( ) { notification . close ( ) ; } ; if ( autoClose ) { setTimeout ( hideNotification , autoClose ) ; } callback ( null , hideNotification ) ; } ; var serviceWorkerRegistration = options . serviceWorkerRegistration ; if ( serviceWorkerRegistration ) { delete options . serviceWorkerRegistration ; if ( ! options . tag ) { tagCounter ++ ; options . tag = 'webnotification-' + Date . now ( ) + '-' + tagCounter ; } var tag = options . tag ; serviceWorkerRegistration . showNotification ( title , options ) . then ( function onCreate ( ) { serviceWorkerRegistration . getNotifications ( { tag : tag } ) . then ( function notificationsFetched ( notifications ) { if ( notifications && notifications . length ) { onNotification ( notifications [ 0 ] ) ; } else { callback ( new Error ( 'Unable to find notification.' ) ) ; } } ) . catch ( callback ) ; } ) . catch ( callback ) ; } else { var instance ; try { instance = new NotificationAPI ( title , options ) ; } catch ( error ) { callback ( error ) ; } //in case of no errors if ( instance ) { onNotification ( instance ) ; } } }
Displays the web notification and returning a 'hide' notification function.

@function
@memberof! webNotification
@alias webNotification.createAndDisplayNotification
@private
@param {String} title - The notification title text (defaulted to empty string if null is provided)
@param {Object} options - Holds the notification data (web notification API spec for more info)
@param {String} [options.icon=/favicon.ico] - The notification icon (defaults to the website favicon.ico)
@param {Number} [options.autoClose] - Auto closes the notification after the provided amount of millies (0 or undefined for no auto close)
@param {function} [options.onClick] - An optional onclick event handler
@param {Object} [options.serviceWorkerRegistration] - Optional service worker registeration used to show the notification
@param {ShowNotificationCallback} callback - Invoked with either an error or the hide notification function
Displays the web notification and returning a hide notification function .