【发布时间】:2016-02-29 07:13:19
【问题描述】:
我正在尝试构建 chrome 推送通知。
我尝试实现从网络引用的随机代码。
代码如下:
notification.html
<script>
function shows(){
var notify= webkitNotifications.createNotification('icon48.png','My notification',
'hi buddy');
notify.show();
}
if(webkitNotifications){
setInterval(function()
{
shows();
}, 1000);
}else{
chrome.tabs.create({url : "error.html"})
}
</script>
而在 error.htm
您的扩展程序中有错误
在 manifest.JSON
中{
"manifest_version": 2,
"name": "My Extension",
"version": "1",
"description" : "Display every 5 sec",
"icons" : {"48" :"icon48.png"},
"permissions" : ["tabs","notifications"],
"background": {"page": "notifications.html"}
}
问题是扩展程序正在 chrome 中加载,但它不响应代码。也没有显示通知。 :(请帮忙。
【问题讨论】:
标签: javascript json web google-chrome-extension push-notification