admin管理员组

文章数量:1427586

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.

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.

Share Improve this question edited Apr 5, 2014 at 15:42 sowbug 4,68223 silver badges29 bronze badges asked Apr 4, 2014 at 18:21 BlynnBlynn 1,4217 gold badges27 silver badges49 bronze badges 3
  • There is a syntax error in there: function(id) {);} should be just function(id) {} – Xan Commented Apr 4, 2014 at 18:23
  • I just updated that bug, but still no luck – Blynn Commented Apr 4, 2014 at 18:26
  • Please update the question to confirm that you're using Linux (which doesn't have support yet for Rich Notifications). Also see github./GoogleChrome/chrome-app-samples/tree/master/… if you don't understand the documentation. – sowbug Commented Apr 5, 2014 at 15:43
Add a ment  | 

1 Answer 1

Reset to default 7

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.

本文标签: javascriptChrome Notification in a packaged app quotchromenotificationscreatequotStack Overflow