Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
[ad_1]
I’m making an attempt to make use of navigator.share
in a file operating in WKWebView on iOS 16. The file is loaded into the online view utilizing a file:
protocol path like so:
uiView.loadFileURL(Bundle.essential.url(forResource: "index", withExtension: "html", subdirectory: "net")!, allowingReadAccessTo: Bundle.essential.bundleURL)
I’ve this setting on:
configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
So I’m able to load file:
protocol recordsdata into the online view, however I do not appear to have the ability to use the Internet Share API. I get this error:
NotAllowedError: The request just isn’t allowed by the person agent or the platform within the present context, presumably as a result of the person denied permission.
Nevertheless, once I level the online view at this HTTPS URL, it really works:
https://mdn.github.io/dom-examples/web-share
This leads me to consider the Internet Share API just isn’t working as a result of the HTML file loaded over the file:
protocol just isn’t considered as safe and thus the JavaScript runtime do not deal with the code on it as if it was operating in a safe context.
In consequence, I consider the entry to the navigator.share
API is forbidden.
Is there a option to configure WKWebView
to permit entry to safe context JS/DOM/net APIs with out utilizing a customized scheme (and including an additional layer atop simply loading my file from the bundle)?
[ad_2]