ServiceWorkerRegistration.getNotifications()
getNotifications()
は ServiceWorkerRegistration
インターフェイスのメソッドで、現在のサービスワーカー登録を介して現在のオリジンから作成された順序で通知のリストを返します。オリジンには、アクティブではあるがスコープが異なるサービスワーカー登録が多数あります。 同じオリジンの 1 つのサービスワーカーによって作成された通知は、同じオリジンの他のアクティブなサービスワーカーでは利用できません。
構文
js
getNotifications()
getNotifications(options)
引数
options
省略可-
返される通知を絞り込むオプションを含むオブジェクト。 使用可能なオプションは次のとおりです。
tag
-
通知タグを表す文字列。 指定した場合、このタグを持つ通知のみが返されます。
返値
Promise
で、 Notification
オブジェクトのリストに解決されます。
例
js
navigator.serviceWorker.register("sw.js");
const options = { tag: "user_alerts" };
navigator.serviceWorker.ready.then((registration) => {
registration.getNotifications(options).then((notifications) => {
// notifications で何かをします
});
});
仕様書
Specification |
---|
Notifications API # dom-serviceworkerregistration-getnotifications |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
getNotifications |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.