ServiceWorkerRegistration
インターフェイスの getNotifications()
メソッドは、現在のサービスワーカー登録を介して現在のオリジンから作成された順序で通知のリストを返します。 オリジンには、アクティブではあるがスコープが異なるサービスワーカー登録が多数あります。 同じオリジンの1つのサービスワーカーによって作成された通知は、同じオリジンの他のアクティブなサービスワーカーでは利用できません。
構文
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) {
// notifications で何かをします
})
});
仕様
仕様 | 状態 | コメント |
---|---|---|
Notifications API ServiceWorkerRegistration.getNotifications() の定義 |
現行の標準 | 初期定義 |
ブラウザーの互換性
BCD tables only load in the browser
The compatibility table in 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.