PushEvent()
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The PushEvent() constructor creates a new PushEvent object. Note that the this constructor is exposed only to a service worker context.
Syntax
const myPushEvent = new PushEvent(type, eventInitDict);
Parameters
- type
-
A
DOMStringdefining the type ofPushEvent. This can bepushorpushsubscriptionchange. - eventInitDict Optional
-
An options object containing any initialization data you want to populate the
PushEventobject with. The options are:-
data: The data you want thePushEventto contain, if any. When the constructor is invoked, thePushEvent.dataproperty of the resulting object will be set to a newPushMessageDataobject containing bytes extracted from theeventInitDict datamember.
-
Example
var dataInit = { data : 'Some sample text' } var myPushEvent = new PushEvent('push', dataInit); myPushEvent.data.text(); // should return 'Some sample text'
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
PushEvent |
42 |
17 |
44
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
|
No |
37 |
No |
No |
42 |
44
48
Push enabled by default.
|
37 |
No |
4.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PushEvent/PushEvent