Since January 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is only available in Service Workers.
The bytes() method of the PushMessageData interface extracts push message data as an Uint8Array object.
bytes()
None.
An Uint8Array.
The returned Uint8Array is backed by an ArrayBuffer of bytes. Exceptions thrown during creation of this backing buffer are re-thrown.
See TypedArray.
self.addEventListener("push", (event) => {
const buffer = event.data.bytes();
// do something with your typed array
});
| Specification |
|---|
| Push API> # dom-pushmessagedata-bytes> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
bytes |
132 | 132 | 128 | 117 | 18 | 132 | 128 | 87 | 18 | No | No | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PushMessageData/bytes