将Chrome“Rich Notification”Api连接到下拉菜单

时间:2016-05-25 18:37:06

标签: google-chrome google-chrome-extension

我正在努力让用户点击Google Chrome浏览器扩展程序上下文菜单中的下拉菜单时创建Chrome通知。任何关于我做错的见解都会非常感激。

侧注:所有这些都连接到Chrome导航栏上的默认弹出窗口,点击后会弹出一个弹出框。

chrome.runtime.onInstalled.addListener(function() {
    var context = "selection";
    var title = "Add To test";
    var id = chrome.contextMenus.create({"title": title, "contexts":[context],
        "id": "context" + context});
});

var options = {
    type: "basic",
    title: "Primary Title",
    message: "Primary message to display",
    iconURL: "test_logo.png"
};

chrome.contextMenus.onClicked.addListener(function() {
    chrome.notifications.create(options, blarg);
});

function blarg() {
    console.log("Pop UP FOR LIFE");
}

1 个答案:

答案 0 :(得分:1)

var options = {
    type: "basic",
    title: "Primary Title",
    message: "Primary message to display",
    iconUrl: "test_logo.png"
};

您必须将iconURL更改为iconUrl。更改后的通知将work

chrome.notifications | examples