Reputation: 416
I am trying to use chrome rich notifications Api in my webpage via Jquery.
Requirement is:
Currently i am not able to get any output from my code:
$(document).ready(function() {
if(chrome.notifications){
chrome_notification_create();
}
});
var chrome_notification_create = function() {
// This is just for later usage not considered now
var options = {
type : "basic",
title : "User Update",
message: "Dear User XYZ U have recieved an 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 an update",
priority:1,
buttons:[{
title:'call'
},
{
title:'send mail'
}
],
isClickable: true
},
function() {
console.log(chrome.runtime.lastError);
}
);
}
The error which i am receiving is : Uncaught TypeError: Cannot read property 'create' of undefined
I have also found this.
which is fulfilling my requirement. BUT my senior wants me to use Chrome API only(As the mozilla one says This is an experimental technology).
So please try to pinpoint the mistake in my code if any. Or any technical detail i might be skipping.
Upvotes: 1
Views: 4965
Reputation: 59
I think you probably forgot to add "notifications" to your permissions in
manifest.json
It should be something like this
{ "permissions": ["notifications", ...] }
Also, you should try to reload your extension.
Upvotes: 3