我第一次创建了Chrome扩展程序。
我在其中使用过chrome.notifications.create,但它不起作用!这是我的密码:
chrome.storage.sync.get('refresh_time',function(items){
status = $('td.c').next().html();
if (status.trim() == 'SomeText') {
alert('Works');
var opt = {
type: "basic",
title: "Project1",
message: "This is my first extension.",
iconUrl: "icons/icon-128.png"
};
chrome.notifications.create('statusChanged', opt, function(){});
}
})我在执行后收到警报,但是铬通知不起作用!你能告诉我我的密码出了什么问题吗?
顺便说一下,我在我的清单文件中使用了下面的代码。
"permissions" : [
"storage",
"notifications",
"tabs"
]发布于 2016-02-28 09:09:16
我觉得密码很好。但是,我想您需要确认iconUrl路径。如果路径指定的文件不存在,则不会显示通知。此时,您可能会在DevTools的console选项卡上看到以下错误消息:
Unchecked runtime.lastError while running notifications.create: Unable to download all specified images.您需要为iconUrl值指定有效路径。
发布于 2021-02-24 17:33:52

对我来说,通知是在windows上禁用的。确保启用“从应用程序和其他发件人获得通知”。
发布于 2022-10-10 09:59:56
我认为您需要将iconUrl作为一个铬扩展路径,如下所示:
iconURL: chrome.runtime.getURL("icons/icon-128.png")https://stackoverflow.com/questions/35672285
复制相似问题