aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/api/pushmanager
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
commit074785cea106179cb3305637055ab0a009ca74f2 (patch)
treee6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/ru/web/api/pushmanager
parentda78a9e329e272dedb2400b79a3bdeebff387d47 (diff)
downloadtranslated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz
translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2
translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip
initial commit
Diffstat (limited to 'files/ru/web/api/pushmanager')
-rw-r--r--files/ru/web/api/pushmanager/index.html115
-rw-r--r--files/ru/web/api/pushmanager/subscribe/index.html144
2 files changed, 259 insertions, 0 deletions
diff --git a/files/ru/web/api/pushmanager/index.html b/files/ru/web/api/pushmanager/index.html
new file mode 100644
index 0000000000..bf1815769e
--- /dev/null
+++ b/files/ru/web/api/pushmanager/index.html
@@ -0,0 +1,115 @@
+---
+title: PushManager
+slug: Web/API/PushManager
+tags:
+ - API
+ - Experimental
+ - Interface
+ - NeedsTranslation
+ - Push
+ - Push API
+ - Reference
+ - Référence(2)
+ - Service Workers
+ - TopicStub
+translation_of: Web/API/PushManager
+---
+<p>{{SeeCompatTable}}{{ApiRef("Push API")}}</p>
+
+<p>Интерфейс <code>PushManager</code> из <a href="/en-US/docs/Web/API/Push_API">Push API</a> предоставляет возможность получать уведомления от сторонних серверов, а также запрашивать URL для push уведомлений.</p>
+
+<p>Этот интерфейс доступен через свойство {{domxref("ServiceWorkerRegistration.pushManager")}}.</p>
+
+<div class="note">
+<p><strong>Заметка</strong>: Этот интерфейс заменил функциональность, предлагаемую устаревшим {{domxref("PushRegistrationManager")}}.</p>
+</div>
+
+<h2 id="Свойства">Свойства</h2>
+
+<dl>
+ <dt>{{domxref("PushManager.supportedContentEncodings")}}</dt>
+ <dd>Возвращает массив со списком возможных алгоритмов кодирования, которые могут быть использованы для шифрования полезной нагрузки пуш-уведомления.</dd>
+</dl>
+
+<h2 id="Методы">Методы</h2>
+
+<dl>
+ <dt>{{domxref("PushManager.subscribe()")}}</dt>
+ <dd>Подписка на пуш сервис. Возвращает промис, который разрешается в {{domxref("PushSubscription")}} объект, содержащий детали новой push подписки.</dd>
+ <dt>{{domxref("PushManager.getSubscription()")}}</dt>
+ <dd>Извлекает существующую push подписку. Возвращает промис, который разрешается в {{domxref("PushSubscription")}} объект, содержащий детали существующей подписки.</dd>
+ <dt>{{domxref("PushManager.permissionState()")}}</dt>
+ <dd>Возвращает {{jsxref("Promise")}}, который разрешается в состояние доступа текущего {{domxref("PushManager")}}, которое может быть одним из <code>'granted'</code>, <code>'denied'</code>, или <code>'default'</code>.</dd>
+</dl>
+
+<h3 id="Устаревшие_методы">Устаревшие методы</h3>
+
+<dl>
+ <dt>{{domxref("PushManager.hasPermission()")}}</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()")}}</dt>
+ <dd>Subscribes to a push subscription. Replaced by {{domxref("PushManager.subscribe()")}}.</dd>
+ <dt>{{domxref("PushManager.registrations()")}}</dt>
+ <dd>Retrieves existing push subscriptions. Replaced by {{domxref("PushManager.getSubscription()")}}.</dd>
+ <dt>{{domxref("PushManager.unregister()")}}</dt>
+ <dd>Unregisters and deletes a specified subscription endpoint. In the updated API, a subscription is can be unregistered via the {{domxref("PushSubscription.unsubscribe()")}} method.</dd>
+</dl>
+
+<h2 id="Пример">Пример</h2>
+
+<pre class="brush: js">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.subscriptionId);
+ 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">Спецификация</th>
+ <th scope="col">Статус</th>
+ <th scope="col">Комментарий</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="/en-US/docs/Web/API/Push_API/Using_the_Push_API">Использование Push API</a></li>
+ <li><a href="http://updates.html5rocks.com/2015/03/push-notificatons-on-the-open-web">Push сообщения в Open Web</a>, Matt Gaunt</li>
+</ul>
diff --git a/files/ru/web/api/pushmanager/subscribe/index.html b/files/ru/web/api/pushmanager/subscribe/index.html
new file mode 100644
index 0000000000..a264d593d7
--- /dev/null
+++ b/files/ru/web/api/pushmanager/subscribe/index.html
@@ -0,0 +1,144 @@
+---
+title: PushManager.subscribe()
+slug: Web/API/PushManager/subscribe
+translation_of: Web/API/PushManager/subscribe
+---
+<p>{{SeeCompatTable}}{{ApiRef("Push API")}}</p>
+
+<p><code style=""><font face="Arial, x-locale-body, sans-serif"><span style="background-color: #ffffff;">Метод </span></font><strong>subscribe()</strong></code> интерфейса {{domxref("PushManager")}} позволяет осуществлять подписку на push-уведомления.</p>
+
+<p>Возвращает {{jsxref("Promise")}}, который разрешается в объект {{domxref("PushSubscription")}}, содержащий детали push-подписки. Новая push-подписка создается в случае, если сервис-воркер не имеет существующей подписки.</p>
+
+<h2 id="Синтакс">Синтакс</h2>
+
+<pre class="syntaxbox">​PushManager.subscribe(options).then(function(pushSubscription) { ... } );</pre>
+
+<h3 id="Свойства">Свойства</h3>
+
+<dl>
+ <dt><code>options {{optional_inline}}</code></dt>
+ <dd>Объект, содержащий необязательные параметры конфигурации. Может иметь следующие свойства:
+ <ul>
+ <li><code>userVisibleOnly</code>: Булевое значение, указывающее на то, будет ли возвращаемая подписка использоваться для сообщений, чей эффект может быть видим для пользователя.</li>
+ <li><code>applicationServerKey</code>: открытый ключ ECDSA P-256, закодированный в Base64 {{domxref ('DOMString')}} или {{domxref ('ArrayBuffer')}}}, содержащий , который push-сервер будет использовать для аутентификации сервера приложений. Если указано, все сообщения с сервера Вашего приложения должны использовать схему аутентификации VAPID и включать JWT, подписанный соответствующим закрытым ключом. Этот ключ <strong><em>НЕ </em></strong>тот же ключ ECDH, который вы используете для шифрования данных. Для получения дополнительной информации см. «<a href="https://blog.mozilla.org/services/2016/04/04/using-vapid-with-webpush/">Using VAPID with WebPush</a>».</li>
+ </ul>
+
+ <div class="blockIndicator note">
+ <p><em><strong>Примечание: </strong>Свойство, требуемое некоторыми браузерами, например Chrome и Edge.</em></p>
+ </div>
+ </dd>
+</dl>
+
+<h3 id="Возвращает">Возвращает</h3>
+
+<p>{{jsxref("Promise")}} который разрешается в объект {{domxref("PushSubscription")}}.</p>
+
+<h2 id="Пример">Пример</h2>
+
+<pre class="brush: js">this.onpush = function(event) {
+ console.log(event.data);
+ <code>// Отсюда можно записывать данные в IndexedDB, отправлять их в любое
+ // открытое окно, отображать уведомление и т. д.</code>
+}
+
+navigator.serviceWorker.register('serviceworker.js').then(
+ function(serviceWorkerRegistration) {
+ serviceWorkerRegistration.pushManager.subscribe().then(
+ function(pushSubscription) {
+ console.log(pushSubscription.subscriptionId);
+ console.log(pushSubscription.endpoint);
+ <code>// Детали push-подписки, требуемые сервером приложения,
+ // теперь доступны, и могут быть отправлены, к примеру,
+ // при помощи XMLHttpRequest.</code>
+ }, function(error) {
+ <code>// При разработке это часто помогает отлавливать ошибки в консоли.
+ // В продакшен-среде это также может быть полезно для отправки отчета
+ // об ошибках на сервер приложения.</code>
+ 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', '#widl-PushManager-subscribe-Promise-PushSubscription--PushSubscriptionOptions-options', 'subscribe()')}}</td>
+ <td>{{Spec2('Push API')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th style="line-height: 16px;">Feature</th>
+ <th style="line-height: 16px;">Chrome</th>
+ <th style="line-height: 16px;">Firefox (Gecko)</th>
+ <th style="line-height: 16px;">Internet Explorer</th>
+ <th style="line-height: 16px;">Opera</th>
+ <th style="line-height: 16px;">Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatChrome(42.0)}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th style="line-height: 16px;">Feature</th>
+ <th style="line-height: 16px;">Android</th>
+ <th style="line-height: 16px;">Android Webview</th>
+ <th style="line-height: 16px;">Firefox Mobile (Gecko)</th>
+ <th style="line-height: 16px;">Firefox OS</th>
+ <th style="line-height: 16px;">IE Mobile</th>
+ <th style="line-height: 16px;">Opera Mobile</th>
+ <th style="line-height: 16px;">Safari Mobile</th>
+ <th style="line-height: 16px;">Chrome for Android</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatChrome(42.0)}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="Смотрите_также">Смотрите также</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/API/Push_API/Using_the_Push_API">Using the Push API</a></li>
+ <li><a href="http://updates.html5rocks.com/2015/03/push-notificatons-on-the-open-web">Push Notifications on the Open Web</a>, Matt Gaunt</li>
+</ul>
+
+<p> </p>
+
+<p> </p>