Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Notifications not appearing from Chrome Extension background page

Using the new chrome.notifications API, I am unable to get notifications from my extension to appear. Even the most basic notification fails to appear for me, but I get no errors and the callback function is properly executed.

manifest.json

{
  "name": "notify",
  "version": "0.0.0",
  "manifest_version": 2,
  "permissions": [
    "notifications"
  ],
  "background": {
    "scripts": ["main.js"]
  }
}

main.js

window.addEventListener('load', function() {
  var opt = {
    type: 'list',
    title: 'Primary Title',
    message: 'Primary message to display',
    priority: 1,
    items: [{ title: 'Item1', message: 'This is item 1.'},
            { title: 'Item2', message: 'This is item 2.'},
            { title: 'Item3', message: 'This is item 3.'}]
  };
  chrome.notifications.create('notify1', opt, function() { console.log('created!'); });
});

When I inspect the background page, I can see "created!" in the console, but I don't ever get a notification on the desktop. I have tried a bunch of different priority values to no avail. What am I doing wrong?

like image 362
smfoote Avatar asked Feb 27 '14 04:02

smfoote


People also ask

Why am I not getting notifications from Google Chrome?

Check your Chrome notification settings Click Settings. Select the Notifications tab. Under "Desktop notifications", click the button next to Chrome to turn notifications on or off.

Can a Chrome extension send a notification?

You can set up Chrome to get notifications, such as meeting reminders, from websites, apps and extensions.


1 Answers

You may have chrome notifications blocked. A good hint this is the case is if you aren't being constantly spammed with notifications from other websites. This answer worked for me.

enable chrome notifications

like image 56
Spankied Avatar answered Oct 02 '22 22:10

Spankied