Can't get HybridWebView to work!

Hi , I am trying to implement the HybridWebView but with no luck for now.

I have in my iOS project:

public override bool FinishedLaunching (UIApplication app, NSDictionary options) {
    global::Xamarin.Forms.Forms.Init ();

    SetIoc ();

    LoadApplication (new App ());

    var hybridWebViewRenderer = new HybridWebViewRenderer ();

    return base.FinishedLaunching (app, options);
}

private void SetIoc() {
    var resolverContainer = new SimpleContainer();

    resolverContainer.Register<IDevice>(r => AppleDevice.CurrentDevice);
    resolverContainer.Register<IJsonSerializer, JsonSerializer> ();

    Resolver.SetResolver(resolverContainer.GetResolver());
}

I am using XLabs.Serialization.JsonNET everywhere.

And also in my PCL:

    var serialization = new XLabs.Serialization.JsonNET.JsonSerializer ();
    var webView = new HybridWebView (serialization) {
            VerticalOptions = LayoutOptions.FillAndExpand,
            HorizontalOptions = LayoutOptions.FillAndExpand
    };

    Content = webView;

    webView.InjectJavaScript("alert('Hello World!);"); // this does not work :(

Acctualy non of the HybridWebView functionality works. I am able to load site like that:

webView.Source = "http://www.google.com/"

But let's say this:

webView.LoadContent("<h1>It's working!</h1>")

is not working.

Posts

  • HristoEnevHristoEnev USMember

    Solved it.

    It was my bad. I was calling .LoadContent and .InjectJavaScript in the constructor of the Page.

Sign In or Register to comment.