Skip to content

Browser Push Notification Blocked Fix

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about Browser Push Notification Blocked Fix. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

Browser push notifications require explicit user permission. When permission is denied, the Notification API cannot display alerts. Common causes include the user blocking notifications, the browser blocking them by default, or calling the API without a user gesture.

The Wrong Way

// Requesting notification without user gesture
Notification.requestPermission().then(permission => {
    if (permission === "granted") {
        new Notification("Hello!");
    }
});

Output:

Notifications may not be shown in browsers that block automatic requests.
Permission state may be "denied" without user interaction.

The Right Way

Request permission in response to a user gesture and handle all states:

<button id="enable-notifications">Enable Notifications</button>
document.getElementById("enable-notifications").addEventListener("click", async () => {
    if (!("Notification" in window)) {
        console.log("Notifications not supported");
        return;
    }

    const permission = await Notification.requestPermission();

    if (permission === "granted") {
        const notification = new Notification("Notifications Enabled", {
            body: "You will now receive updates.",
            icon: "/icon.png"
        });

        notification.onclick = () => {
            window.focus();
            notification.close();
        };
    } else if (permission === "denied") {
        console.warn("Notifications blocked");
        showNotificationInstructions();
    }
});

function showNotificationInstructions() {
    const info = document.createElement("div");
    info.textContent = "Please enable notifications in your browser settings.";
    document.body.appendChild(info);
}

Step-by-Step Fix

1. Check current notification permission

function getNotificationStatus() {
    if (!("Notification" in window)) {
        return "unsupported";
    }
    return Notification.permission;
}

const status = getNotificationStatus();
if (status === "denied") {
    console.log("User has blocked notifications for this site");
} else if (status === "granted") {
    console.log("Notifications already enabled");
} else {
    console.log("Permission not yet requested");
}

2. Guide users to re-enable notifications

function showEnableGuide() {
    const instructions = {
        chrome: "Settings > Privacy and Security > Site Settings > Notifications",
        firefox: "Options > Privacy & Security > Permissions > Notifications",
        safari: "Preferences > Websites > Notifications"
    };
    console.log(`Enable in ${instructions.chrome}`);
}

3. Use service worker for push notifications

// Register service worker
navigator.serviceWorker.register("/sw.js");

// Subscribe to push
async function subscribeToPush() {
    const registration = await navigator.serviceWorker.ready;
    const subscription = await registration.pushManager.subscribe({
        userVisibleOnly: true,
        applicationServerKey: urlBase64ToUint8Array("PUBLIC_VAPID_KEY")
    });
    console.log("Push subscription:", subscription);
}

4. Handle denied permission gracefully

if (Notification.permission === "denied") {
    // Use in-app notifications instead
    showInAppNotification("Important update available");
}

function showInAppNotification(message) {
    const badge = document.createElement("div");
    badge.className = "in-app-notification";
    badge.textContent = message;
    document.body.appendChild(badge);
}

5. Check for quiet mode

// Some browsers have "quiet notification" days
navigator.permissions.query({name: "notifications"}).then(status => {
    if (status.state === "denied") {
        console.log("Notifications denied");
    }
    status.onchange = () => {
        console.log("Permission changed:", status.state);
    };
});

Prevention Tips

  • Always request notification permission in response to a user click.
  • Explain the value of notifications before requesting permission.
  • Handle all permission states (granted, denied, default) gracefully.
  • Provide an in-app notification fallback when push is blocked.
  • Detect and show instructions when notifications are blocked at the browser level.

Common Mistakes with notification blocked

  1. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  2. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  3. Misunderstanding that String is [Char] with poor performance for large text operations

These mistakes appear frequently in real-world BROWSER code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### How do I reset notification permission?

In Chrome: click the lock icon in the address bar > Site Settings > Notifications > Reset. Users can also go to chrome://settings/content/notifications to manage per-site permissions.

What is the difference between Notification and Push API?

Notification API displays local notifications within the browser. Push API allows servers to send messages to the browser even when the page is not open, using a service worker.

Why are notifications blocked by default?

Chrome and Firefox block notification requests by default because they were frequently abused for spam. Sites must request permission explicitly, and users can permanently block unwanted sites.

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro