I have a Xamarin.Forms app and it projected to WASM via Uno Platform . I need open a web link after click or tap. I solve it with:
try // Uwp & iOS & Android
{
await Browser.OpenAsync(new Uri("http://localhost"), BrowserLaunchMode.SystemPreferred); // Open url in-app browser for iOS & Android- native in UWP
}
catch (NotImplementedInReferenceAssemblyException ex) //Wasm falls here because lack of Xamarin.Essentials.
{
await DisplayAlert("Hata", "Not supported on WASM", "Anladım"); // Show the info about exception.
}
for Xamarin. Android & iOS and UWP(Windows). However, the Xamarin.Essentials cannot run on WASM yet. So I need to invoke the Javascript and run this code:
function openPage(x) {
window.open(x);
}
I try to use UNO.Foundation for
WebAssemblyRuntime.InvokeJS("(function(){location.href=\"https://www.wikipedia.com/\";})();");
However, it interfere with the UWP UI classes and brokes my project. How can I invoke Javascript from Xamarin.Forms page C# backend without using UNO.Foundation class ? Thanks.