Requesting permission to send notifications

suggest change

Notification.requestPermission asks whether the page may show notifications. Call it from a user gesture. Current browsers require a secure context. The callback form is obsolete. The method returns a promise that fulfills with "granted", "denied", or "default". A denial is that string, not a rejection. Notification.permission is read-only.

Notification.requestPermission().then(function(permission) {
    if (permission === "granted") {
        // new Notification(...) can succeed
    } else if (permission === "denied") {
        // the user denied permission
    } else {
        // "default": the user dismissed the prompt
    }
});

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents