I have a simple call to the chrome.notifications.create(id,options) function and I have checked the arguments ten times already.
The id argument is a string. The options argument is an object like this:
{type:"basic",message:"message",title:"message",iconUrl:chrome.extension.getURL("icons/icon.png")}
It is only working in Firefox though. Edge Opera and Chrome all fail to display the notification. Edge just crashes!
I've checked everything. There are no errors and the iconUrl is correct.
Also I checked the name field of the manifest json. It's fine. (Microsoft Edge notification in an extension)
Sample relevant and simplified code
This simplified version has the same problem as the complete one.
//For hooking up event handlers
try {
chrome.runtime.onStartup.addListener(doHandshake);
}catch(ex) {
console.error("onStartup function in Edge is not supported.");
}
chrome.webRequest.onBeforeRequest.addListener(onBeforeRequestCallback, { types:['main_frame'],urls:['*://*/*']}, ['blocking']);
function onBeforeRequestCallback(requestDetails) {
showMessage();
return {};
}
function showMessage() {
console.log("about to show notification...");
var notificationOptions ={type:"basic",message:"msg",title:"title",iconUrl:chrome.extension.getURL("icons/icon.png")};
chrome.notifications.create("",notificationOptions);
}
The manifest.json
{
"manifest_version": 2,
"author" : "whatever Ltd.",
"name": "21charsName",
"version": "1.0",
"description": "whatever",
"permissions": [
"*://*/*",
"tabs",
"webRequest",
"webRequestBlocking",
"storage",
"notifications"
],
"browser_action": {
"default_icon": "icons/icon.png",
"default_title": "extension"
},
"background": {
"scripts": [
"background.js"
],
"persistent": true
},
"web_accessible_resources": []
}