Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

WebView / HybridWebView C# Javascript communication

$
0
0

This has been a long standing pain. The Xamarin.Forms webview does not provide any api to handle C# to Javascript and Javascript to C#. Even after hoping something will be come about after the grand Evolve 2014 that concluded this month.

Then I looked in to HybridWebView from Xamarin Forms Labs. And I just can not get it to work on iOS. It's such a simple code example and I am surprised it doesn't work. I must be missing something.

Any ideas?

My Xamarin Forms page has this code:

`var wv = new HybridWebView
{
HeightRequest = 300
};

        wv.Source = new UrlWebViewSource { Url = "http://compname/HybridWebViewTestApp/index.html" };
        wv.LoadFinished += (object sender, EventArgs e) =>
        {
            Console.WriteLine("loaded");  // DOES NOT WORK, Never gets called
        };


        callJsButton.Clicked += (object sender, EventArgs e) =>
        {
            wv.CallJsFunction("showMessage", "hello");  // DOES NOT WORK

        };`

index.html (showing only what's inside the script tag)

`function showMessage(msg) {

  document.write(msg);

}`


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>