CustomRenderer-WebView-Unable to render Javascript in iOS RRS feed

  • Question

  • User395873 posted

    Unable to render the attached index html in Xamarin iOS. This html uses FreshDesk javascript widget.

    I referenced this sample: https://github.com/xamarin/xamarin-forms-samples/tree/master/CustomRenderers/HybridWebView

    Expected Behavior This widget works great in UWP but not in iOS. Attached screenshot is an example of how it looks in UWP. index html should render the same as UWP in iOS.

    Actual Behavior Index html renders blank screen in iOS.

    Information IDE and IDE version: Visual Studio 2019 v16.6.4 Platform with the issue: iOS: SDK Device or simulator/emulator: Both

    I also enabled the key permissions in info.plist. Not sure what I am missing here.

    Tuesday, August 18, 2020 12:03 PM

All replies

  • User382871 posted

    On iOS, this HTML file resides in the Content folder of the platform project, with a build action of BundleResource. Please make sure the build action is correct.

    Check the tutorial: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/webview?tabs=windows#ios

    Tuesday, August 18, 2020 1:38 PM
  • User395873 posted

    I tried setting it as BundleResource, it didnt work

    Tuesday, August 18, 2020 4:15 PM
  • User382871 posted

    Try to enable the javacript function for the WKWebView. ``` protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e);

    if (e.OldElement != null)
        WKWebViewConfiguration configuration = new WKWebViewConfiguration();
        this.Configuration.Preferences = new WKPreferences { JavaScriptEnabled = true };

    } ```

    Here is the tutorial about the webView renderer, you can check it. https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/hybridwebview

    Wednesday, August 19, 2020 7:54 AM