How to use UIWebView in the Xamarin.Forms iOS part?

Pelin Konaray 291 Reputation points
2023-01-26T11:10:54.5066667+00:00

Hi,

I have a Xamarin.Forms application. I integrated Airwatch SDK (WorkspaceOne.Forms) into the iOS part.

Now, I am trying to app tunneling with Airwatch SDK. For this reason I have added ModernHttpClient Handler to all of the HttpClients on my project. (Following the link: https://developer.vmware.com/web/workspace-one/tutorials/Xamarin-iOS/App-Tunneling/Airwatch-SDK)

When I do this, I can connect with tunnel on my app. Http post and get requests work in this way with no problem. But my app has webviews. Webviews don't open.

I saw that app tunneling is supported with UIWebView (not supported with WKWebView). I know UIWebView is deprecated I can't publish it to the AppStore. But I wonder if I use UIWebView, does it work? For this reason I tried to custom renderer for UIWebView like following code.

<custom:CustomWebView Source="{Binding WebViewSource}" />

public class CustomWebView : WebView
{
}

[assembly: ExportRenderer(typeof(CustomWebView), typeof(CustomWebViewRenderer))]
namespace App.iOS.CustomRenderer
{
    public class CustomWebViewRenderer : ViewRenderer<WebView, UIWebView>
    {
        protected override void Dispose(bool disposing)
        {
            GC.Collect();
        }
    }
}

But I couldn't be sure of this technique is true. Because UIWebView deprecated and it is not supported with new Xamarin.Forms versions. I inherited CustomWebView from WebView. If Xamarin.Forms is not supported UIWebView in the new versions, when I code like this custom renderer, can I use UIWebView?

If I make a custom renderer like this, do I use UIWebView or do I use WKWebView? I'm confused. How can I try UIWebView?

Thanks in advanced.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,292 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,261 Reputation points Microsoft Vendor
    2023-01-27T05:37:33.02+00:00

    Hello,

    You can not use webview in the WatchOS. See this document about native iOS Web views.

    No additional considerations for iOS, iPadOS, or macOS. Not supported in tvOS or watchOS.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.