Open AlohaJava opened 4 years ago
Webview doesn't load html? wrong path?
I've not found an exact information yet, but I guess at least iOS 13.7 doesn't allow WKWebView access to local files under /private/var/containers/Bundle/Application/.../....app/Data/Raw. This is inconveniet but should make the app more secure. WKWebView can access /var/mobile/Containers/Data/Application/.../Documents/ and copying html files to it - which is done by the sample app - still works.
I've not found an exact information yet, but I guess at least iOS 13.7 doesn't allow WKWebView access to local files under /private/var/containers/Bundle/Application/.../....app/Data/Raw. This is inconveniet but should make the app more secure. WKWebView can access /var/mobile/Containers/Data/Application/.../Documents/ and copying html files to it - which is done by the sample app - still works.
So @KojiNakamaru -san , the fix is to not allow WKWebView on iOS? Like: webViewObj.Init(enableWKWebView: false);
I'd just like to ask since I have the same problem where the WebView is just a plain white screen on iOS. It works perfectly fine on Android though.
In case the enableWKWebView
setting is not the problem, can I ask what is it that causes the WebView to be just a plain white screen in this code snippet? Am I missing a configuration setting somewhere?
webViewObj.Init(
cb: elementClickCallback,
ld: msg => elementClickCallback?.Invoke(PREFIX_WEBVIEW_ON_LOADED + msg),
started: msg => elementClickCallback?.Invoke(PREFIX_WEBVIEW_ON_STARTED + msg),
hooked: msg => elementClickCallback?.Invoke(PREFIX_WEBVIEW_ON_HOOKED + msg),
enableWKWebView: true);
webViewObj.EvaluateJS(@"Unity.call('ua=' + navigator.userAgent)");
webViewObj.EvaluateJS(@"
document.body.addEventListener(
'click',
function() {
Unity.call('callback', window.location.href);
});
");
webViewObj.SetMargins(0, marginTop, 0, marginBottom, true);
webViewObj.SetVisibility(true);
if (shouldLoadHTMLBody)
{
webViewObj.LoadHTML(html, string.Empty);
}
else
{
webViewObj.LoadURL(url);
}
webViewObj.SetURLPattern("", "", ".*");
Also mentioning here that the iOS model and version my team used for testing (that breeds the white screen display) are: iPhoneSE (OS version: 14.3), iPhone 8 (OS version: 12.1.3), and iPhone XR (OS version: 13).
Hello, I am using the latest version of unity-webview. It works good on Android and iOS Simulator, but doesn't work on iOS build ( doesn't load html).
Local path generator
And using
What can cause this behavior?