pusher / push-notifications-flutter

Official Pusher Beams Flutter client plugin (iOS, Android and Web), receive notifications easily on your Flutter application with Pusher Beams.
https://pub.dev/packages/pusher_beams
MIT License
10 stars 27 forks source link

Web: Failed to register a ServiceWorker #13

Closed MeenaAlfons closed 2 years ago

MeenaAlfons commented 2 years ago

When running the web version with chrome, I get the following error in flutter logs and Chrome console.

Code:

void main() async {
  const instanceID = '00000000-0000-0000-0000-000000000000';
  await PusherBeams.instance.start(instanceID);
  await PusherBeams.instance.setDeviceInterests(['debug-new', 'hello']);

  runApp(const MyApp());
}

Command:

flutter run -d chrome

Error:

DOMException: Failed to register a ServiceWorker for scope ('http://localhost:59347/') with script ('http://localhost:59347/service-worker.js?pusherBeamsWebSDKVersion=1.0.3'): The script
has an unsupported MIME type ('text/html').

I think related to this error is the fact that the first notification I send appears as follows:

Publish Command:

curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer <token>" \
     -X POST "https://00000000-0000-0000-0000-000000000000.pushnotifications.pusher.com/publish_api/v1/instances/00000000-0000-0000-0000-000000000000/publishes" \
     -d '{"interests":["hello"],"web":{"notification":{"title":"Hello","body":"Hello, world!"}}}'

Received notification: Screenshot 2022-01-07 at 12 33 41

And later notifications don't appear at all.