PushEvent()
PushEvent()
コンストラクターは、新しい PushEvent
オブジェクトを生成します。このコンストラクターは、サービスワーカーにのみ公開されていることに注意してください。
構文
new PushEvent(type)
new PushEvent(type, options)
引数
type
-
文字列で、イベントの名前を示します。 大文字小文字の区別があり、ブラウザーは
push
またはpushsubscriptionchange
に設定します。 options
省略可-
オブジェクトで、
ExtendableEvent()
で定義されているプロパティに加えて、以下のプロパティを指定することができます。data
-
PushEvent
に格納したいデータ(もしあれば)。コンストラクターが呼び出されると、結果オブジェクトのPushEvent.data
プロパティには、これらのバイト列を格納した新しいPushMessageData
オブジェクトが設定されます。
返値
新しい PushEvent
オブジェクトです。
例
const dataInit = {
data : 'Some sample text'
}
const myPushEvent = new PushEvent('push', dataInit);
myPushEvent.data.text(); // 'Some sample text' を返す
仕様書
Specification |
---|
Push API # dom-pushevent-constructor |
ブラウザーの互換性
BCD tables only load in the browser