0

I was previousely using webkit notifications on my website but it seems to have deprecated, I am trying the rich notifications but they seem to be not working either. I tried almost all the available demos online but none of them work. Are the Rich notifications deprecated, if so what could be the possible ways of displaying desktop notifications in chrome. I checked the chrome flags and I coudnt find the rich notifications options.

This was the code I was trying for rich notifications

 setInterval(timedpopup, 1000);
function timedpopup(){
chrome.notifications.create('report',{
type:'basic',
title:'hello world',
iconUrl: '',
message:'this is a message',
expandedMessage:'Hello World!!!!!!!!!',
priority:1,
buttons:[{title:'Cancel'},{title:'Got it'}],
isClickable:true
},function(){});
}

This gives the error: Uncaught TypeError: Cannot read property 'create' of undefined This is the code that was working earlier:

    setInterval(timedpopup, 2000);
function timedpopup(){
webkitNotifications.createNotification("", "This is a message", "HELLO WORLD").show();
}

This gives error: Uncaught ReferenceError: webkitNotifications is not defined

I tried to check it on the chrome documentation but it doesnt say anything about rich notifications being deprecated.

Please let me know if there are any alternatives for notifications. Any input on this context is appreciated

Thanks

Priyanshu
  • 70
  • 1
  • 2
  • 9

2 Answers2

2

Rich Notifications are not deprecated. However, they are only usable inside a Chrome Extension/App and are not exposed to normal websites.

One can make a "companion" extension for a website that will provide access to Chrome APIs, but that would require asking users to install it.

The direct replacement for webkitNotifications is indeed HTML5 Notification.

Community
  • 1
  • 1
Xan
  • 74,770
  • 16
  • 179
  • 206
  • Thanks for the answer Xan.. But I think that they are deprecated. I am not too sure what a Content Script is, but the same code worked on older version of chromes so I dint doubt the code. Can you post your code that's working and the chrome version (Mine is 37). I would love to make the rich notifications work again :) – Priyanshu Oct 30 '14 at 15:44
  • Okay, what exactly do you call "Rich Notifications"? `chrome.notifications`? They perfectly work, here's the [documentation](https://developer.chrome.com/extensions/notifications). Here's [my extension](https://chrome.google.com/webstore/detail/da-message-notifier/ocinjngecpdhlnhggcnhjdpengmifjdl) that uses them. Here's [a snippet from its code](https://gist.github.com/kav2k/fb96cc8c061d3cbfb250) that works with them. – Xan Oct 30 '14 at 15:51
  • I took the first part of your code and saved it in a html file.. if(chrome.notifications){ console.log("notifications available"); setInterval(timedpopup, 1000); } else { console.log("notifications not available"); } And I get 'notifications not available' in the console. I checked chrome flags and the options to enable rich notifications isn't there. It used to be there when I had rich notifications working.. Am I doing it wrong ? – Priyanshu Oct 30 '14 at 17:11
  • I saved the above code in a js file and included it in a html file.. still get 'notifications not available'. If I am getting it right, Content Script means js script in html page, and background page is a .js file.. am I right?(I know you have included the link for content script but it seems rather complicated) – Priyanshu Oct 30 '14 at 17:37
  • Ah, sorry! I completely misread that. They are only available to extensions. Not available for general sites. I'm going to delete my answer. – Xan Oct 30 '14 at 17:42
  • Thats what I was about to request.. Its the best answer so far :) – Priyanshu Oct 30 '14 at 17:53
-1

See: Chrome webkitNotification not found : api missing

And: https://developer.chrome.com/extensions/notifications

And Finally, under "Chrome Notes" https://developer.mozilla.org/en/docs/Web/API/notification

Community
  • 1
  • 1
Chris Fremgen
  • 4,649
  • 1
  • 26
  • 26
  • Thanks for the links, Although I went through these before posting the question. Anyways, I got the notifications working again after a careful reading on the mozilla link, but I am still struggling with the chrome notifications. – Priyanshu Jul 08 '14 at 17:13