Are Chrome rich notifications deprecated

元气小坏坏 提交于 2020-01-17 02:58:09

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/24632983/are-chrome-rich-notifications-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!