Web Push notification payload ist null when sending ArrayBuffer

Viewed 84

I am trying to send binary data from a Node.js server to a JavaScript service worker using the Web Push API.

On the Node.js side I use the web-push library and send the message with

webpush.sendNotification(subscription, buffer)

I get a status 201 and I receive the push message on the browser side. When I look at the Push Messaging log in the DevTools, I can even see the binary payload (encoded as UTF-8), and it says that the message was encrypted.

But when I try to get the ArrayBuffer in the service worker like this, event.data is null:

self.addEventListener('push', function (event) {
    console.log(event.data);
})

I don't understand how the data can be null if it was received by the client side.

0 Answers
Related