How to Load local HTML file in a native web browser in Xamarin Forms?
For Eg: Android mobile need to open in android mobile browser For iOS: iPhone need to open Safari For UWP: Windows need to open Internet Explorer
How to Load local HTML file in a native web browser in Xamarin Forms?
For Eg: Android mobile need to open in android mobile browser For iOS: iPhone need to open Safari For UWP: Windows need to open Internet Explorer
Unfortunately, it is not supported in iOS, you only can use the method like [[UIApplication sharedApplication] openURL:url];
to open Safari app to browse a link, but not a file in local. You can refer to Open local html file with Safari
which is related with iOS.
In Android, you have to copy the html file to the shared storage instead of using the path like assets. Otherwise, the browser can't reach the file. Please refer to how open local html page in browser.
I am not familiar with UWP, but I found this: [UWP]How to launch default web browser on local app HTML file/images?. It looks like it's also not friendly to achieve that in UWP.
Maybe, you have to consider WebView instead.
Is it necessary to open in native web browser? Maybe you could use a WebView
WebView can display content from HTML, CSS and Javascript embedded within the app. For example:
<html>
<head>
<title>Xamarin Forms</title>
</head>
<body>
<h1>Xamrin.Forms</h1>
<p>This is an iOS web page.</p>
<img src="XamarinLogo.png" />
</body>
</html>
To display local content using a WebView, you'll need to open the HTML file like any other, then load the contents as a string into the Html property of an HtmlWebViewSource. For more information on opening files, see Working with Files.
Or just use:
var browser = new WebView();
var htmlSource = new HtmlWebViewSource();
htmlSource.Html = @"<html><body>
<h1>Xamarin.Forms</h1>
<p>Welcome to WebView.</p>
</body></html>";
browser.Source = htmlSource;