PushEvent.PushEvent()
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.
The PushEvent()
constructor creates a new PushEvent
object. Note that the this constructor is exposed only to a service worker context.
Syntax
JavaScript
Copy Code
var myPushEvent = new PushEvent(type, <span id="idl-def-PushEvent" class="idlInterface">eventInitDict</span>);
Parameters
- type
- A
DOMString
defining the type ofPushEvent
. This can bepush
orpushsubscriptionchange
. - eventInitDict Optional
- An options object containing any initialization data you want to populate the
PushEvent
object with. The options are:data
: The data you want thePushEvent
to contain, if any. When the constructor is invoked, thePushEvent.data
property of the resulting object will be set to a newPushMessageData
object containing bytes extracted from theeventInitDict data
member.
Example
JavaScript
Copy Code
var dataInit = { data : 'Some sample text' } var myPushEvent = new PushEvent('push', dataInit); myPushEvent.data.text(); // should return 'Some sample text'
Specifications
Specification | Status | Comment |
---|---|---|
Push API The definition of 'PushEvent' in that specification. |
Working Draft | Initial definition. |
Browser Compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 42.0 | 44.0 (44.0)[1][2] | No support | ? | No support |
data property |
No support | 44.0 (44.0)[2] | 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 | 48.0 (48)[3] | No support | No support | No support | No support | 42.0 |
data property |
No support | No support | 48.0 (48)[3] | No support | No support | No support | No support | No support |
- [1] Currently enabled in Nightly/Developer Edition/Beta by default, but not in the Release channel (bug 1208560.)
- [2] Push (and Service Workers) have been disabled in the Firefox 45 Extended Support Release (ESR.)
- [3] Push has been enabled by default on Firefox for Android version 48.
See also
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/pushevent/pushevent