I'm trying to display some content in Xamarin IOS app using WKWebView. The code is pretty straightforward:
public override void ViewDidLoad()
{
base.ViewDidLoad();
var simpleWebView = new WKWebView(View.Frame, new WKWebViewConfiguration());
Add(simpleWebView);
simpleWebView.NavigationDelegate = new WKWebViewDelegate();
simpleWebView.LoadRequest(new NSUrlRequest(new NSUrl("https://myurl_here")));
}
public class WKWebViewDelegate : WKNavigationDelegate
{
public override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
{
WKJavascriptEvaluationResult handler = (NSObject result, NSError err) => {
if (err != null)
{
//Do smth
}
if (result != null)
{
//Do smth
}
};
webView.EvaluateJavaScript("(function() { return ('<html>' + document.getElementsByTagName('html')[0].innerHTML + '</html>'); })(); ", handler);
}
}
This works fine in simulator in iOS 13, but in iOS 11 I'm getting blank screen despite the fact that in the NavigationDelegate I can check that content from web was loaded without errors. What's the problem with WKWebView in iOS 11?