You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i load my html from an sqlite database on iOS, and all the images relative to this HTML in downloaded on the device in the persistentdatapath.
Using
However, WKWebView forbits file:// URLs for loadHtmlString:baseURL: so it won't load your images. For avoiding the issue, please put the main html under Application.persistentDataPath and call LoadURL() as done in the sample app.
Does it mean that this package won't work with file:// URLs embedded in a web page as well, unless you switch to UIWebView? I am asking because WKWebView is required by Apple nowadays.
Also wondering how the situation is for Android 10.
(We are currently using UniWebView and have problems with exact this. We need access to a local file that is actually a screen shot of the native Augmented Reality camera. It seems as if this worked in UniWebView before, but now is broken. I was wondering if we could use your package instead.)
This plugin just utilizes native Android WebView and/or iOS WKWebView/UIWebView components. The allowFileAccessFromFileURLs seems to work but is not officially supported.
However, as described above, WKWebView (since iOS9) allows to load local files if you use LoadURL() instead of LoadHTML(). The sample app in this repository actually loads a local sample.html by LoadURL(), and sample.js and sample.jpg, both are referred in sample.html, are correctly loaded.
Please note the sample app first writes these files into Applicaiton.persistentDataPath and then load sample.html. You can therefore dynamically generate any webview content locally under Applicaiton.persistentDataPath for your webview.
// NOTE: a more complete code that utilizes UnityWebRequest can be found in https://github.com/gree/unity-webview/commit/2a07e82f760a8495aa3a77a23453f384869caba7#diff-4379160fa4c2a287f414c07eb10ee36d
Activity
KojiNakamaru commentedon Jul 25, 2017
Replace("/", "//")will replace every/in the string so it should be removed. The following modification works for UIWebView (enableWKWebView:false).However, WKWebView forbits
file://URLs forloadHtmlString:baseURL:so it won't load your images. For avoiding the issue, please put the main html underApplication.persistentDataPathand callLoadURL()as done in the sample app.derwaldgeist commentedon Jun 8, 2020
Hi, I just stumbled upon this.
Does it mean that this package won't work with file:// URLs embedded in a web page as well, unless you switch to UIWebView? I am asking because WKWebView is required by Apple nowadays.
There is a flag to tell WKWebView that it may allow this:
https://bugs.webkit.org/show_bug.cgi?id=154916#c7
Is this implemented in this package?
Also wondering how the situation is for Android 10.
(We are currently using UniWebView and have problems with exact this. We need access to a local file that is actually a screen shot of the native Augmented Reality camera. It seems as if this worked in UniWebView before, but now is broken. I was wondering if we could use your package instead.)
KojiNakamaru commentedon Jun 8, 2020
This plugin just utilizes native Android WebView and/or iOS WKWebView/UIWebView components. The
allowFileAccessFromFileURLsseems to work but is not officially supported.https://stackoverflow.com/questions/36013645/setting-disable-web-security-and-allow-file-access-from-files-in-ios-wkwebvi/41266699#41266699
However, as described above, WKWebView (since iOS9) allows to load local files if you use
LoadURL()instead ofLoadHTML(). The sample app in this repository actually loads a local sample.html byLoadURL(), and sample.js and sample.jpg, both are referred in sample.html, are correctly loaded.https://github.com/gree/unity-webview/tree/ac10622fc470d1886444b9462eecd131f3469488/sample/Assets/StreamingAssets
Please note the sample app first writes these files into
Applicaiton.persistentDataPathand then load sample.html. You can therefore dynamically generate any webview content locally underApplicaiton.persistentDataPathfor your webview.unity-webview/sample/Assets/Scripts/SampleWebView.cs
Lines 119 to 148 in ac10622
Android 10 seems to have many troubles about WebView, but these should be reduced by updating Android System WebView from Google Play.