Xamarin Forms WebView Advanced Series

The Xamarin Forms WebView control is an abstraction of the platform specific Android WebView, iOS UIWebView and UWP WebBrowser controls. It allows you to view HTML and run Javascript from a local or remote source.

While the WebView seems like an odd control to have in a mobile app, it continues to serve a variety of purposes, such as automating a login process in the background, viewing internal web pages, or even having an API based content management system providing HTML, and needing to be rendered on the mobile app. It’s a control I never like using, but one that seems to seep into many projects, due to API’s limitations on authentication or as a way to render easily changeable content.

In this series are several posts about many things you can configure, to make your life easier.

webview

Bindable Methods

If you want to use Refresh or GoBack, you will need to extend the WebView control to make it accessible in your ViewModel.

Executing Javascript

The Xamarin Forms webview control has a way to inject javascript into the page, but it doesn’t allow a return value. This will show you how to retrun the results from a Javascript call.

Debugging the WebView

You can actually debug the WebView, via Chrome from your Desktop to an emulator or real device. This process is fantastic at debugging certain issues.

Cookie Sharing

WebViews normally share cookies with your HTTPClient, with the exception of Android, which needs some extra help. This post goes through how it is shared and how to clear cookies from the shared Cookie Container.

Rendering Engine Configuration

Each platform uses a different web rendering engine. Further to this, different versions of the same platform, have different rendering engines, this also includes the Javascript rendering engine. I will go through some differences.


XAMARIN.FORMS MONTHLY NEWSLETTER

JOIN 1,100+ SUBSCRIBERS

  1. Don't miss out on updates
  2. The latest info from this site, Xamarin and the community
  3. Unsubscribe at any time*

* We use MailChimp, with double opt-in, and instant unsubscribe

Microsoft MVP | Xamarin MVP | Xamarin Certified Developer | Exrin MVVM Framework | Xamarin Forms Developer | Melbourne, Australia

Related Posts