Here is my code. I'm not sure whether this is supposed to work.

$('#save').bind('click', function(e){

var opt = {
    type: "basic",
    title: "Deploy",
    message: "It worked!"
  };
chrome.notifications.create("", opt, function(id) {});
});

I have my permissions set up to use notifications, so I think that isn't the problem.

有帮助吗?

解决方案

Note that the documentation lists iconUrl as a required option for opt in chrome.notifications.create.

So suppose you add a picture icon.png to the root of your extension. Then your code can be modified like that:

var opt = {
   type: "basic",
   title: "Deploy",
   message: "It worked!",
   iconUrl: "icon.png"
};
chrome.notifications.create("", opt, function(id) {
   if(chrome.runtime.lastError) {
     console.error(chrome.runtime.lastError.message);
   }
});

This should work, and in case there is any problem with the notification you'll get informed in the console.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top