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
var myPushEvent = new PushEvent(type, eventInitDict);
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
var dataInit = {
data : 'Some sample text'
}
var myPushEvent = new PushEvent('push', dataInit);
myPushEvent.data.text(); // should return 'Some sample text'
Browser compatibility
BCD tables only load in the browser