Replace WebView with WKWebView in Xamarin Forms application

uiwebviewwkwebviewxamarin.forms

I have a webview inside my Xamarin Forms application which opens report downloaded from server in html format. Today I uploaded my archived application to app store and get information about ITMS-90809: UIWebView API Deprecation.

The problem is that I have no idea how to replace UIWebView with WKWebView in cross platform application. I've tried several solutions:

1) Creating Custom renderer for WebView – but this is no solution really because I need to inherit my new class by WebView superclass. So Apple warn me again with the same message.

2) Creating dependency service and use custom renderer in ios project only. But this is the same problem – there is still WebView reference in shared project.

So, is there any way to inject WKWebView directly to StackLayout in iOS? I know that WKWebView is iOS only and StackLayout is Xamarin.Forms component but really I don't have any idea how to do this.

Can anyone help me?

Best Answer

There is an issue in Github you can follow: Deprecated API Usage UIWebView

WebViewRenderer in iOS implements UIWebView, and the file stays even if you switch over the WkWebViewRenderer. That's why you get the error message.

Xamarin team is working on it and it will fixed sometime in the future.

Also, there is an Apple statement says:

The App Store will no longer accept new apps using UIWebView as of April 2020 and app updates using UIWebView as of December 2020.

So you can still submit app with UIWebView right now and the error messgae is just a warning.

Relevant links: Make WkWebViewRenderer default for iOS WebView

Related Topic