Chrome Extension notifications【谷歌浏览器扩展之弹窗通知】
2017-09-04 10:37
896 查看
起初为方便快速使用的是 alert ,后优化时发现并使用 notifications API 来代替。
使用 chrome.notifications API 须先配置 manifest 文件中的 permissions :
调用示例:
使用 chrome.notifications API 须先配置 manifest 文件中的 permissions :
"permissions": [ "notifications", "downloads", "storage" ]
调用示例:
chrome.notifications.getPermissionLevel(function(level){ //获取用户是否为当前应用或应用启用通知(permissions中已配置可直接调用notifications) if( level == 'granted' ){ //发出通知, type 默认为 basic chrome.notifications.create( 'notify_alert1', // notifyId {type: "basic", iconUrl: "icon-48.png", title: "更新完成!", message: "请查看页面数据是否已更新。"}, function(notifyId){ //不用移除该消息,否者不会显示 // chrome.notifications.clear(notifyId, function(){ }); } ); }else{ //... alert('更新完成!') } });
相关文章推荐
- Chrome Extension Ajax & downloads【谷歌浏览器扩展之Ajax和下载】
- 谷歌浏览器桌面通知 HTML5 Chrome Desktop Notifications
- Chrome Extension manifest【谷歌浏览器扩展之配置】
- Chrome Extension sendMessage & sendRequest【谷歌浏览器扩展之消息通信】
- Chrome Extension options_page & storage【谷歌浏览器扩展之选项页和storage】
- 下载谷歌浏览器(Chrome)扩展离线安装包crx文件最简单的方法
- 解除谷歌浏览器Chrome无法安装扩展插件的限制(图文教程):
- 谷歌浏览器插件 离线安装 AXURE RP EXTENSION For Chrome
- 下载谷歌浏览器(Chrome)扩展crx文件
- Mozilla Firefox Extension扩展 内幕 教程 源代码分析 安装过程分析(XPInstall,xpcom,rdf,xpi,chrome,manifest)
- Chrome插件开发实例 – 时间通知(notifications)
- chrome 桌面通知 Notifications 用法
- 将Chrome(谷歌浏览器)扩展程序打包为crx文件
- 分享Chrome Extension(扩展程序/插件)开发的一些小经验
- 解除谷歌浏览器Chrome无法安装扩展插件的限制~
- 谷歌浏览器(chrome) —— 扩展应用程序
- 谷歌浏览器chrome插件、扩展程序无法下载的解决方法
- JavaScript编写Chrome扩展实现与浏览器的交互及时间通知
- Chrome notifications -- Chrome 浏览器消息通知中心