aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/pushmanager/index.html
blob: f42fb127abd354d0069377499c0553e79460b495 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
title: PushManager
slug: Web/API/PushManager
tags:
  - API
  - Experimental
  - Interface
  - Push
  - Push API
  - Reference
  - Service Workers
  - 푸시
  - 푸시 알림
translation_of: Web/API/PushManager
---
<p>{{ApiRef("Push API")}}</p>

<p><a href="/ko/docs/Web/API/Push_API">Push API</a><strong><code>PushManager</code></strong> 인터페이스는 서드파티 서버에서 알림을 수신하거나, URL에 푸시 알림을 요청하는 방법을 제공합니다.</p>

<p><code>PushManager</code>{{domxref("ServiceWorkerRegistration.pushManager")}} 속성으로 접근할 수 있습니다.</p>

<h2 id="속성">속성</h2>

<dl>
 <dt>{{domxref("PushManager.supportedContentEncodings")}}</dt>
 <dd>푸시 메시지의 페이로드를 암호화할 때 지원하는 콘텐츠 인코딩의 목록을 반환합니다.</dd>
</dl>

<h2 id="메서드">메서드</h2>

<dl>
 <dt>{{domxref("PushManager.getSubscription()")}}</dt>
 <dd>기존의 푸시 구독을 가져옵니다. 해당 구독에 대한 상세 정보를 담은 {{domxref("PushSubscription")}} 객체를 {{jsxref("Promise")}}로 반환합니다. 구독이 존재하지 않으면 프로미스는 <code>null</code>로 이행합니다.</dd>
 <dt>{{domxref("PushManager.permissionState()")}}</dt>
 <dd>PushManager의 허가 상태로 이행하는 {{jsxref("Promise")}}를 반환합니다. 상태는 <code>'granted'</code>, <code>'denied'</code>, <code>'prompt'</code> 중 하나입니다.</dd>
 <dt>{{domxref("PushManager.subscribe()")}}</dt>
 <dd>푸시 서비스에 구독합니다. 해당 구독에 대한 상세 정보를 담은 {{domxref("PushSubscription")}} 객체를 {{jsxref("Promise")}}로 반환합니다. 현재 서비스 워커에 이전 구독이 존재하지 않으면 새로운 푸시 구독을 생성합니다.</dd>
</dl>

<div class="hidden">
<h3 id="Deprecated_methods">Deprecated methods</h3>

<dl>
 <dt>{{domxref("PushManager.hasPermission()")}} {{deprecated_inline}}</dt>
 <dd>Returns a {{jsxref("Promise")}} that resolves to the <code>PushPermissionStatus</code> of the requesting webapp, which will be one of <code>granted</code>, <code>denied</code>, or <code>default</code>. Replaced by {{domxref("PushManager.permissionState()")}}.</dd>
 <dt>{{domxref("PushManager.register()")}} {{deprecated_inline}}</dt>
 <dd>Subscribes to a push subscription. Replaced by {{domxref("PushManager.subscribe()")}}.</dd>
 <dt>{{domxref("PushManager.registrations()")}} {{deprecated_inline}}</dt>
 <dd>Retrieves existing push subscriptions. Replaced by {{domxref("PushManager.getSubscription()")}}.</dd>
 <dt>{{domxref("PushManager.unregister()")}} {{deprecated_inline}}</dt>
 <dd>Unregisters and deletes a specified subscription endpoint. In the updated API, a subscription is unregistered by calling the {{domxref("PushSubscription.unsubscribe()")}} method.</dd>
</dl>
</div>

<h2 id="예제">예제</h2>

<pre class="brush: js notranslate">this.onpush = function(event) {
  console.log(event.data);
  // From here we can write the data to IndexedDB, send it to any open
  // windows, display a notification, etc.
}

navigator.serviceWorker.register('serviceworker.js').then(
  function(serviceWorkerRegistration) {
    serviceWorkerRegistration.pushManager.subscribe().then(
      function(pushSubscription) {
        console.log(pushSubscription.endpoint);
        // The push subscription details needed by the application
        // server are now available, and can be sent to it using,
        // for example, an XMLHttpRequest.
      }, function(error) {
        // During development it often helps to log errors to the
        // console. In a production environment it might make sense to
        // also report information about errors back to the
        // application server.
        console.log(error);
      }
    );
  });</pre>

<h2 id="명세">명세</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Push API','#pushmanager-interface','PushManager')}}</td>
   <td>{{Spec2('Push API')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="브라우저_호환성">브라우저 호환성</h2>

<div>


<p>{{Compat("api.PushManager")}}</p>
</div>

<h2 id="같이_보기">같이 보기</h2>

<ul>
 <li><a href="/ko/docs/Web/API/Push_API">Push API</a></li>
 <li><a href="/ko/docs/Web/API/Service_Worker_API">Service Worker API</a></li>
</ul>