registerServiceWorker method
Re-registers the plugin's service worker with a custom url and/or
scope, replacing the automatically registered bundled worker.
url: script URL of a custom worker — e.g. a copy ofjs_notifications-sw.jsextended with app-specific message handling (see sendAction). When null, the bundled worker asset is used — pass onlyscopeto keep the bundled worker but register it under a custom scope:
// bundled worker, custom scope
await JsNotificationsPlatform.instance
.registerServiceWorker(scope: "/js_notifications/");
// custom worker, default scope
await JsNotificationsPlatform.instance
.registerServiceWorker(url: "/my_notifications-sw.js");
scope: registration scope. When null the browser default (the script's directory) is used. A scope outside the script's directory requires the server to send aService-Worker-Allowedresponse header — for the bundled asset (served fromassets/packages/js_notifications/assets/) any broader scope needs that header configured on the hosting server.
Implementation
@override
Future<void> registerServiceWorker({String? url, String? scope}) {
return serviceWorkerManager.registerServiceWorker(url: url, scope: scope);
}