Open runspired opened 9 years ago
This code fixes the build, however WKWebView doesn't allow interception of network requests which means the plugin doesn't (can't ?) work anyway.
@jamessharp hrm, so it's still goof for a lot of the uses of a service worker (data sync), but not for asset cacheing. I'm ok with that personally since on cordova I'm serving from local assets, but would be nice if this was possible. Does the cordova-whitelist plugin not intercept?
Yes, I suspect everything but asset cacheing/interception will work OK (I haven't tested it though). Chrome on iOS is still using UIWebView because of this issue (among other things). See this meta-bug for discussion. You could hack round it for XHR requests by using something like xhook but I don't think it's possible for standard requests (images, css, fonts etc).
@jamessharp That's right, there's no way to intercept network requests with WKWebView; this plugin won't work with cordova-plugin-wkwebview-engine, at least for fetch events.
@runspired, I don't believe that cordova-whitelist works on WKWebView either; the suggestion there is to use CSP to control what the web content of your application has access to
If you haven't already, you should open issue tickets with Apple for both ServiceWorker support (I've already done so) and for wkWebView to support intercepting network requests (I'm about to do so).
@jamessharp @clelland I've often wondered if you could "hook" the src
attribute of img
and script
programmatically, I'll investigate that. Alternative idea, a script included before anything else that grabs src
and link
attributes from script
img
and link
and removes them, then adds a path from cache returned by the service worker.