--- title: PushManager slug: Web/API/PushManager tags: - API - API de armazenamento - Experimental - Interface - Referencia - Service Workers - Subir dados translation_of: Web/API/PushManager ---
{{SeeCompatTable}}{{ApiRef("Push API")}}
A PushManager
interface da API Push fornece uma maneira de receber notificações de servidores de terceiros, bem como solicitar URLs para notificações push.
Essa interface é acessada através da propriedade {{domxref ("ServiceWorkerRegistration.pushManager")}}.
Nota : Esta interface substitui a funcionalidade anteriormente oferecida pela interface obsoleta {{domxref ("PushRegistrationManager")}}.
null
valor.'granted'
, 'denied'
ou 'prompt'
.PushPermissionStatus
do webapp requerente, que será um dos granted
, denied
ou default
. Substituído por {{domxref ("PushManager.permissionState ()")}}.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);
}
);
});
Especificação | Status | Comentário |
---|---|---|
{{SpecName('Push API','#pushmanager-interface','PushManager')}} | {{Spec2('Push API')}} | Definição inicial. |
Característica | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Ópera | Safari (WebKit) |
---|---|---|---|---|---|---|
Suporte básico | {{CompatChrome(42)}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop (44.0)}} [1] | {{CompatNo}} | {{CompatOpera (29)}} | {{CompatNo}} |
supportedContentEncodings propriedade |
{{CompatChrome (60)}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatOpera (47)}} | {{CompatNo}} |
Característica | Android Webview | Chrome para Android | Edge | Firefox Mobile (Gecko) | SO Firefox | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Suporte básico | {{CompatChrome (42)}} | {{CompatChrome (42)}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile (48)}} [2] | {{CompatNo}} | {{CompatNo}} | {{CompatOperaMobile (29)}} | {{CompatNo}} |
supportedContentEncodings propriedade |
{{CompatChrome (60)}} | {{CompatChrome (60)}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatNo}} | {{CompatOperaMobile (47)}} | {{CompatNo}} |