How to use chrome.notifications.create() in my webpage -
i trying use chrome rich notifications api in webpage via jquery.
requirement is:
- i want send desktop notifications user using website.
currently not able output code:
$(document).ready(function() { if(chrome.notifications){ chrome_notification_create(); } }); var chrome_notification_create = function() { // later usage not considered var options = { type : "basic", title : "user update", message: "dear user xyz u have recieved update", iconurl: "outsourcing.png" } chrome.notifications.create( 'id1', { type:'basic', iconurl:chrome.runtime.geturl("img/dan_logo2_128_padded.png"), title : "user update", message: "dear user xyz u have recieved update", priority:1, buttons:[{ title:'call' }, { title:'send mail' } ], isclickable: true }, function() { console.log(chrome.runtime.lasterror); } ); }
the error receiving : uncaught typeerror: cannot read property 'create' of undefined
i have found this.
which fulfilling requirement. senior wants me use chrome api only(as mozilla 1 says experimental technology).
so please try pinpoint mistake in code if any. or technical detail might skipping.
i think forgot add "notifications" permissions in
manifest.json
it should this
{ "permissions": ["notifications", ...] }
also, should try reload extension.
Comments
Post a Comment