来自后台脚本的桌面通知 [英] Desktop notification from background script

查看:57
本文介绍了来自后台脚本的桌面通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是chrome扩展程序开发的初学者.我正在尝试在后台脚本完成某些方法时显示桌面通知,但我不知道该如何请求权限.有什么办法可以完成这项任务?

I'm beginner in chrome extensions development. I'm trying to show desktop notifications when my background script finishes some of its methods but i don't know how i can request permissions for this. Is there any way to accomplish this task?

可以使用内容脚本来完成,但是我想通过后台脚本显示通知,而没有后台页面.

It can be done using content script, but I want to show notifications by background script, without background page.

推荐答案

您需要将通知添加到manifest.json文件:

You need to add notifications to your manifest.json file:

"permissions": ["tabs", "notifications","management"]

然后您可以致电

webkitNotifications.createNotification('images/message48.png', title, message);

这篇关于来自后台脚本的桌面通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆