この記事は編集レビューを必要としています。ぜひご協力ください。
これは実験段階の機能です。
この機能は複数のブラウザーで開発中の状態にあります。互換性テーブルをチェックしてください。また、実験段階の機能の構文と挙動は、仕様変更に伴い各ブラウザーの将来のバージョンで変更になる可能性があることに注意してください。
ServiceWorkerRegistration インターフェースの getNotifications() メソッドは、現在の service worker から発火した通知リストを返します。
構文
ServiceWorkerRegistration.getNotifications(options).then(function(NotificationsList) { ... });
引数
- options Optional
- 通知返却をフィルタするおぶしょんを含めることが出来るオプションオブジェクト。使用可能なオプションは以下の通り:
tag: 通知タグを表すDOMString。指定した場合、このタグを持つ通知のみ返される。
戻り値
Notification オブジェクトのリストに解決される Promise。
例
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 ServiceWorkerRegistration.getNotifications() の定義 |
現行の標準 | 初期定義。 |
ブラウザー実装状況
| 機能 | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| 基本サポート | 40.0 | 44.0 (44.0)[1] | 未サポート | 24 | 未サポート |
| 機能 | Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
|---|---|---|---|---|---|---|---|
| 基本サポート | ? | 44.0 (44.0) | ? | 未サポート | ? | 未サポート | ? |
[1] Service workers(と Push)は 、Firefox 45 延長サポート版 (ESR)では使用できません。