Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
Notification.requestPermission does not fire when it is automatically blocked by Chrome

So basically I have button which when clicked will trigger a call to Notification.requestPermission and depending on the users response I do some action.

The issue is that Notification.requestPermission does not actually fire when it is automatically blocked by Chrome.

This is my code

function askNotificationPermission(handler) {

    // checks to see if notification is actually supported
    function checkNotificationPromise() {
        try {
            // checks if promise based notification is okay
            Notification.requestPermission().then();
        } catch(e) {
            return false;
        }
        return true;
    }

    // Let's check if the browser supports notifications
    if (!('Notification' in window)) {
        console.log("This browser does not support notifications.");
    } else {

        if(checkNotificationPromise()) {
            window.console.log("requesting permission...")
            Notification.requestPermission()
                .then((permission) => {
                    window.console.log("PERMISSION", permission)
                    handler(permission);

                    window.console.log("finished handler")

                })

            window.console.log("done", Notification.permission)
        } else {
            Notification.requestPermission(function(permission) {
                handler(permission);
            });
        }
    }
}

Is there anyway to catch when notifications are automatically blocked?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!