MDN self-hosted library · e01.org

PushMessageData: bytes() method

Push APIservice

Push APIservice

The bytes() method of the PushMessageData interface extracts push message data as a Uint8Array object.

Syntax

bytes()

Parameters

None.

Return value

A Uint8Array.

Exceptions

The returned Uint8Array is backed by an ArrayBuffer of bytes. Exceptions thrown during creation of this backing buffer are re-thrown.

See TypedArray.

Examples

self.addEventListener("push", (event) => {
  const buffer = event.data.bytes();

  // do something with your typed array
});

Specifications

Browser compatibility