Error when using chrome.notifications.create "Uncaught TypeError: Cannot read property 'create' of undefined"
There are 2 possible causes.
You are trying to use this from a content script. You can't: content scripts are very limited in what Chrome APIs they can call.
However, content scripts have some limitations. They cannot:
Use chrome.* APIs, with the exception of:
extension
(getURL
,inIncognitoContext
,lastError
,onRequest
,sendRequest
)
i18n
runtime
(connect
,getManifest
,getURL
,id
,onConnect
,onMessage
,sendMessage
)
storage
In that case, you need to delegate this call to a background script: send a message from the content script, get it in a background script and execute the action.
You are trying to call it from an extension script, but did not declare the
"notifications"
permission.In that case the fix is trivial - just add the permission.
Have you added the chrome notifications permissions to your manifest.json?
adding permissions: ["notifications",//other permissions here]
The permissions deals with what is and isnt loaded in your extension, and what you have access too.