ably / ably-js

Javascript, Node, Typescript, React, React Native client library SDK for Ably realtime messaging service
https://ably.com/download
Apache License 2.0
317 stars 55 forks source link

Push notifications error: "Registration failed - push service error" #1920

Closed spacycoder closed 3 days ago

spacycoder commented 3 days ago

Hi, i'm trying to setup push notifications in a sveltekit app. When I active push with client.push.activate() I get this error:

Error: Failed to register service worker
    at getW3CPushDeviceDetails (pushactivation.ts:10:21)Caused by: DOMException: Registration failed - push service error

Any idea what I could be doing wrong? This is my service-worker.js file:

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

code:

const client = new Ably.Rest({
      authUrl: '/api/ably/token-request',
      pushServiceWorkerUrl: '/service-worker.js',
      plugins: { Push }
});

client.push.activate();

This is where it fails: https://github.com/ably/ably-js/blob/18a255948c38d1e60715c8f5d6173369b57cb8d6/src/plugins/push/getW3CDeviceDetails.ts#L59C5-L62C8

┆Issue is synchronized with this Jira Task by Unito

spacycoder commented 3 days ago

Seems to be a browser problem. Works fine on firefox, but not on microsoft edge for linux