Firefoxのデベロッパー版(バージョン54.0a2を使用していますが、バージョン51の通常のFirefoxを試しました)を使用しており、Web拡張機能に通知を含めたいとします。Web拡張機能(Firefox)で通知が機能しない
ブラウザー["通知"]が存在しません。
私の拡張機能では機能しませんでしたし、何かが矛盾していると思われたので、私はこの非常に基本的なWeb拡張機能を作成しました。
manifest.jsonを:アドオンがdoesn'tいずれかのいずれかのエラーを示してデバッグ
{
"manifest_version": 2,
"name": "Extension",
"version": "1.0",
"description": "...",
"icons": {
"48": "icons/icon-48.png"
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": ["test.js"]
}
],
"permissions": ["notifications", "storage"]
}
test.js(記憶ところでだけで正常に動作します。)
if (browser["notifications"]) {
console.log('Notifications exist!');
browser.notifications.create({
"type": "basic",
"iconUrl": browser.extension.getURL("icons/icon-48.png"),
"title": "test",
"message": "test"
});
}
else {
//it always executes this part :/
console.log('notifications do not exist');
console.log(browser);
}
。
あなたはバックグラウンドスクリプトで通知を作成する必要があると思います。ここには簡単な例があります:https://github.com/mdn/webextensions-examples/tree/master/notify-link-clicks-i18n – juvian
ありがとう、それは今動作します! – Michael