I am trying to load a web application (Readium) in a Webview with Xamarin.Forms locally. As a target I have UWP, Android and iOS.
I can not get the page index.html open, I have embedded the Web in each of the projects, according to link but I get a blank page.
I have implemented the dependency service for each application of the form (UWP)
assembly: Dependency(typeof(BaseUrl))]
namespace WorkingWithWebview.UWP
{
public class BaseUrl : IBaseUrl
{
public string Get()
{
return "ms-appx-web:///";
}
}
}
However, creating a new UWP project (without Xamarin), it does work well for me to load the application, using the NavigateToLocalStreamUri (uri, new StreamUriWinRTResolver ()) method with
public sealed class StreamUriWinRTResolver : IUriToStreamResolver
{
public IAsyncOperation<IInputStream> UriToStreamAsync(Uri uri)
{
if (uri == null)
{
throw new Exception();
}
string path = uri.AbsolutePath;
return GetContent(path).AsAsyncOperation();
}
private async Task<IInputStream> GetContent(string path)
{
try
{
Uri localUri = new Uri("ms-appx:///cloud-reader" + path);
StorageFile f = await StorageFile.GetFileFromApplicationUriAsync(localUri);
IRandomAccessStream stream = await f.OpenAsync(FileAccessMode.Read);
return stream;
}
catch (Exception)
{
throw new Exception("Invalid path");
}
}
}
How would the same thing be done in Xamarin.Forms? Thanks in advance.