blob: f2da1b2832bf0a0c964efa218f300c2031c3c4f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
---
title: ServiceWorkerRegistration.getNotifications()
slug: Web/API/ServiceWorkerRegistration/getNotifications
tags:
- API
- Experimental
- Method
- Notification
- Notifications
- Reference
- Service Worker
- Service Workers
- Service worker API
- ServiceWorker
- ServiceWorkerRegistration
- getNotifications
translation_of: Web/API/ServiceWorkerRegistration/getNotifications
---
<div>{{APIRef("Service Workers API")}}</div>
<p><span class="seoSummary">{{domxref("ServiceWorkerRegistration")}} インターフェイスの <code>getNotifications()</code> メソッドは、現在のサービスワーカー登録を介して現在のオリジンから作成された順序で通知のリストを返します。 オリジンには、アクティブではあるがスコープが異なるサービスワーカー登録が多数あります。 同じオリジンの1つのサービスワーカーによって作成された通知は、同じオリジンの他のアクティブなサービスワーカーでは利用できません。</span></p>
<h2 id="Syntax" name="Syntax">構文</h2>
<pre class="syntaxbox"><em>serviceWorkerRegistration</em>.getNotifications(<em>options</em>)
.then(function(<em>notificationsList</em>) { ... });</pre>
<h3 id="Parameters" name="Parameters">パラメーター</h3>
<dl>
<dt>options {{optional_inline}}</dt>
<dd>返される通知をフィルタするオプションを含むオブジェクト。 使用可能なオプションは次のとおりです。
<ul>
<li><code>tag</code>: 通知タグを表す {{domxref("DOMString")}}。 指定した場合、このタグを持つ通知のみが返されます。</li>
</ul>
</dd>
</dl>
<h3 id="Return_value" name="Return_value">戻り値</h3>
<p>{{domxref("Notification")}} オブジェクトのリストに解決される {{jsxref("Promise")}}。<br>
</p>
<h2 id="Example" name="Example">例</h2>
<pre class="brush: js">navigator.serviceWorker.register('sw.js');
var options = { tag : 'user_alerts' };
navigator.serviceWorker.ready.then(function(registration) {
registration.getNotifications(options).then(function(notifications) {
// notifications で何かをします
})
});</pre>
<h2 id="Specifications" name="Specifications">仕様</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">仕様</th>
<th scope="col">状態</th>
<th scope="col">コメント</th>
</tr>
<tr>
<td>{{SpecName('Web Notifications', '#dom-serviceworkerregistration-getnotifications', 'ServiceWorkerRegistration.getNotifications()')}}</td>
<td>{{Spec2('Web Notifications')}}</td>
<td>初期定義</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
<p>{{Compat("api.ServiceWorkerRegistration.getNotifications")}}</p>
|