Desktop Notification not appearing in Chrome

Viewed 9409

I've verified that Notification.permission === 'granted', and, 'Notification' in window == true, altho the following Javascript does not make a notification appear in my Chrome browser, Version 70.0.3538.77 (Official Build) (64-bit).

var notif = new Notification('title', {
    icon: 'https://placehold.it/120x120',
    body: 'body'
});

I've executed the above in Chrome Console on the site that I know I've previously Allowed for Desktop Notifications. I've also verified that it's set to Allow in this location:Notifications set to Allow

5 Answers

Had same issue recently. Solution for me was disabling "Enable native notifications" in chrome://flags . And the reason why I wasnt able to see notifications is because browser wanted to show native notification, and I disabled all windows notifications. Hope it will help someone in future :)

Okay, I'm writing just in case anyone finds it useful.

I encountered this problem as well and I tried different sites without success. However, @Don Reptile answer gave me a hint as to what may be wrong (I blocked native notifications).

I'm on Windows 10 and this was where I enabled native notifications from Chrome.

Enable Windows Native Notifications

Issue of not opening dialog box is http. Chrome desktop notification work only on https protocol.

I have faced this issue and I have spend many time to solved that. Finally I got solution using https.

Here I shared code so you can run on https and it will working fine.

// request permission on page load
document.addEventListener('DOMContentLoaded', function() {
  if (!Notification) {
    alert('Desktop notifications not available in your browser. Try Chromium.');
    return;
  }

  if (Notification.permission !== "granted")
    Notification.requestPermission();
});

function notifyMe() {
  if (Notification.permission !== "granted")
    Notification.requestPermission();
  else {
    var notification = new Notification('Notification title', {
      icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
      body: "Hey there! You've been notified!",
    });

    notification.onclick = function() {
      window.open("http://stackoverflow.com/a/13328397/1269037");
    };
  }
}

notifyMe();

Call notifyMe(); to show notification

On my machine, MacOS had chrome notifications blocked at an OS level.

Fix was: System Preferences > Notifications & Focus > Enable Chrome

In MacOS, you need to change the settings in your laptop.

  1. Open "System Preferences".
  2. Search for "Notifications & Focus".
  3. Select "Google Chrome" from list of applications.
  4. Enable "Allow Notifications"
Related