记得要开启chrome通知权限,右下角,对话图标,打开通知栏,点右上角管理通知,找到chrome,开启
文档:https://developer.chrome.com/docs/extensions/reference/notifications/
manifest.json
"permissions": [ "notifications" ],
service-worker.js
// 提醒 function notify(text) { chrome.notifications.create(getNotificationId(), { title: 'title', iconUrl: './images/logo.png', type: 'basic', message: text }, function (ret) { console.log('retnotret', ret) }); } // Returns a new notification ID used in the notification. function getNotificationId() { var id = Math.floor(Math.random() * 9007199254740992) + 1; return id.toString(); }
标签:function,getNotificationId,浏览器,chrome,win,谷歌,notifications,通知 From: https://www.cnblogs.com/jqynr/p/17537026.html