Javascript 如何在我的chrome扩展中访问chrome通知API?
根据:我需要这样做:Javascript 如何在我的chrome扩展中访问chrome通知API?,javascript,google-chrome-extension,notifications,Javascript,Google Chrome Extension,Notifications,根据:我需要这样做: const notification = () => { var options = { type : "basic", title : "Some title", message: "Some message", iconUrl: "icons/icon19.png" // YES this png does exist } chrome.notifications.create( 'id_1'
const notification = () => {
var options = {
type : "basic",
title : "Some title",
message: "Some message",
iconUrl: "icons/icon19.png" // YES this png does exist
}
chrome.notifications.create(
'id_1',
options,
function() {
console.log(chrome.runtime.lastError);
}
);
}
但是,当我运行扩展时,我得到一个错误:uncaughttypeerror:无法读取未定义的属性“create”
我在manifest.json
"permissions": [
"https://target-site.org/*",
"notifications"
],
我也尝试过做console.log(chrome)代码>
它返回不包含通知的对象。这就是它的输出:
如何访问chrome扩展项目中的通知?内容脚本无法使用大多数扩展API。使用背景或浏览器操作脚本。谢谢!将尝试