Chrome浏览器丰富的通知是否被弃用

Chrome浏览器丰富的通知是否被弃用

本文介绍了Chrome浏览器丰富的通知是否被弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前曾在我的网站上使用过webkit通知,但似乎已被弃用,我正在尝试丰富的通知,但它们似乎也无法正常工作。
我尝试了几乎所有可用的演示,但都没有工作。
是否推荐使用Rich通知,如果是这样的话,可能是以chrome显示桌面通知的可能方式。
我查了一下chrome标志,并发现了丰富的通知选项。



这是我尝试发送丰富通知的代码。

  setInterval(timedpopup,1000); 
函数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(){});





$ p这会给出错误:Uncaught TypeError:无法读取未定义的属性'create'
这是之前工作的代码:

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





这会给出错误:Uncaught ReferenceError:webkitNotifications未定义



我试图在chrome文档中查看它,但它没有提及任何有关已被弃用的丰富通知。



请让我知道有任何通知的替代品。
在此上下文中的任何输入值得赞赏


谢谢

解决方案

not 不推荐使用。然而,它们只能在Chrome扩展程序/应用程序中使用,并且不会暴露于普通网站。


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 undefinedThis 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

解决方案

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.

这篇关于Chrome浏览器丰富的通知是否被弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 17:06