Enable service worker selectively

In my app, I have several WKWebViews. The WKWebViews communicate to javascript by installing userscripts.

Now one of those webviews, wants to enable support for service workers, which is not required in the other instances of WKWebView.

So what I thought, is that I only enable in this WKWebView instance the service worker, which sets limitsNavigationsToAppBoundDomains in its WKWebViewConfiguration to true. And so the service worker is enabled and works fine and also my WKUserScript works fine.

In the other WKWebView instances I thought, that I would simply set limitsNavigationsToAppBoundDomains to false and the service worker would be disabled and WKAppBound domains from the Info.plist would be ignored.

Unfortunately my WKUserScript now stopped working. :-( How can I achieve that? Does the presence of WKAppBound domains in the Info.plist mean, that I MUST set limitsNavigationsToAppBoundDomains to true for my WKUserScript to work?

Or am I on the completely wrong track?

Any help is greatly appreciated, because I am pretty much stuck with this issue and I need to solve it, because the limitation to 10 domains from WKAppBoundDomains carries the risk to break the webview. In that webview payment is provided and the payment provider might at any time change dependencies to another domain (as happened recently, which broke the payment page)

Best regards Alex

Any progress?

Enable service worker selectively
 
 
Q