getNotifications()
方法在
ServiceWorkerRegistration
interface returns a list of the notifications in the order that they were created from the current origin via the current service worker registration. Origins can have many active but differently-scoped service worker registrations. Notifications created by one service worker on the same origin will not be available to other active services workers on that same origin.
serviceWorkerRegistration.getNotifications(options)
.then(function(notificationsList) { ... });
tag
: A
DOMString
representing a notification tag. If specified, only notifications that have this tag will be returned.
A
Promise
that resolves to a list of
Notification
对象。
navigator.serviceWorker.register('sw.js');
var options = { tag : 'user_alerts' };
navigator.serviceWorker.ready.then(function(registration) {
registration.getNotifications(options).then(function(notifications) {
// do something with your notifications
})
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
Notifications API
The definition of 'ServiceWorkerRegistration.getNotifications()' in that specification. |
实时标准 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getNotifications
|
Chrome 40 |
Edge
17
|
Firefox
46
|
IE No | Opera 27 | Safari 11.1 | WebView Android No | Chrome Android 40 | Firefox Android 46 | Opera Android 27 | Safari iOS 11.3 | Samsung Internet Android 4.0 |
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
用户必须明确启用此特征。
ServiceWorkerRegistration
getNotifications()
showNotification()
unregister()
update()