Esta traducción está incompleta. Por favor, ayuda a traducir este artículo del inglés.
This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
La API Push otorga a las aplicaciones web la habilidad de recibir mensajes enviados a ellas desde un servidor, sin importar si la aplicación está o no en primer plano o cargada. Esto permite a los desarrolladores enviar notificaciones asíncronas y actualizaciones para los usuarios que las aceptan.
Nota: Esta documentación cubre la especificación del API Push de W3C; si estás buscando la documentación para el mecanismo push propio de Firefox OS, ve Simple Push.
Push concepts and usage
PushSubscription includes all the information that the application needs to send a push message: an endpoint and the encryption key needed for sending data.
The service worker will be started as necessary to handle incoming push messages, which are delivered to the
ServiceWorkerGlobalScope.onpush event handler. This allows apps to react to push messages being received, for example by displaying a notification (using
Each subscription is unique to a service worker. The endpoint for the subscription is a unique capability URL: knowledge of the endpoint is all that is necessary to send a message to your application. The endpoint URL therefore needs to be kept secret, or other applications might be able to send push messages to your application.
Activating a service worker to deliver a push message can result in increased resource usage, particularly of the battery. Different browsers have different schemes for handling this — there is currently no standard mechanism. Firefox allows a limited number of push messages to be sent to an application. This limit is refreshed each time that the site is visited. In comparison, Chrome applies no limit but requires that applications show a notification each time that a push message is received, which allows the user to confirm that they still want to receive notifications and ensures user visibility.
Note: Chrome currently requires you to set up a project on Google Cloud Messaging to send push messages, and use the associated project number and API key when sending push notifications. It also requires an app manifest with some special parameters to use this service. This restriction will hopefully be removed in the future.
- Represents a push action sent to the global scope of a
ServiceWorker. It contains information sent from an application to a
- Provides a way to receive notifications from third-party servers as well as request URLs for push notifications. This interface has replaced functionality offered by the obsolete
- Provides access to push data sent by a server, and includes methods to manipulate the received data.
- Provides a subcription's URL endpoint and allows unsubscription from a push service.
Service worker additions
The following additions to the Service Worker API have been specified in the Push API spec, to provide an entry point for using Push messages, and to monitor and respond to push and subscription change events.
- Returns a reference to the
PushManagerinterface for managing push subscriptions including subscribing, getting an active subscription, and accessing push permission status. This is the entry point into using Push messaging.
- An event handler fired whenever a
pushevent occurs; that is, whenever a server push message is received.
- An event handler fired whenever a
pushsubscriptionchangeevent occurs; for example, when a push subscription has been invalidated, or is about to be invalidated (e.g. when a push service sets an expiration time.)
|Push API||Working Draft||Initial definition|
|Feature||Chrome||Firefox (Gecko)||Internet Explorer||Opera||Safari (WebKit)|
|Basic support||42.0||44.0 (44.0)||?||?||?|
||No support||44.0 (44.0)||No support||No support||No support|
|Feature||Android||Android Webview||Firefox Mobile (Gecko)||Firefox OS||IE Mobile||Opera Mobile||Safari Mobile||Chrome for Android|
|Basic support||No support||No support||No support||No support||?||?||?||42.0|
||No support||No support||No support||No support||No support||No support||No support||No support|
 Currently available only on desktop versions of Firefox; also, push messages are only delivered when Firefox is running.