service_worker
service_worker copied to clipboard
Cannot read property 'new' of undefined
Hello,
I am getting errors in the example.
I just changed
import 'package:service_worker/service_worker.dart';
to
import 'package:service_worker/worker.dart';
And I am getting the following in the web console:
`
MAIN: registereddart_sdk.js:18740
MAIN: ready dart_sdk.js:18740
MAIN: Sending message: Sample message: 2019-06-18 10:52:26.908 dart_sdk.js:18740
MAIN: Message sent: Sample message: 2019-06-18 10:52:26.908 main.dart:34
Uncaught (in promise) TypeError: Cannot read property 'new' of undefined `
Where new is used there:
var subs = await registration.pushManager .subscribe(new sw.PushSubscriptionOptions(userVisibleOnly: true));
AFAICR worker
is for on-page web worker, and with that it may not have access to the pushManager. But my memory is really vague on this one, I haven't done deep web coding for ages...