Why doesn't the notification function of chrome work?

after testing, you will be asked whether to turn on notification on chrome, but there is no notification of the arrival of the message. In Firefox, 2345 has a notification effect.
2345: 5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.90 Safari/537.36 2345Explorer/9.4.2.17629
chrome 5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36

the code is as follows:

Notification.requestPermission(function (permission) {

// If the user accepts, let"s create a notification
    if (!("Notification" in window)) {

        alert("");

    }
});
function notifyFunc(tag,title,body,icon) {


// check whether notification permissions have alredy been granted

    if (Notification.permission == "granted") {

// If it"s okay let"s create a notification

        var notification = new Notification(title, {
            body: body,
            icon: icon,
            tag: tag,
            renotify: true
        });
        notification.onclick = function() {
            //notificationtab
            window.focus();
            notification.close();
        }

    }

// Otherwise, ask the user for permission

    else if (Notification.permission != "denied") {

        Notification.requestPermission(function (permission) {

// If the user accepts, let"s create a notification

            if (permission == "granted") {

                new Notification("Request granted!");

            }

        });

    }
}

does anyone know why?


online test or local test. If the online test does not come out, it may be the reason for the protocol (Google security restrictions), just use https . Locally, it is the browser version. If you have encountered it before, just change the version.

Menu