2

I have integrated the WebView widget from webview_flutter into my flutter application. The problem I am facing is that WebView works perfectly on Android, but on iOS WebView doesn't recognize button taps.

Widget build(BuildContext context) {
    var mediaQuery = MediaQuery.of(context);
    return SingleChildScrollView(
      child: SizedBox(
        height: mediaQuery.size.height - 60 - mediaQuery.padding.top,
        child: WebView(
          initialUrl: widget.url,
          javascriptMode: JavascriptMode.unrestricted,
          javascriptChannels: {
            _extractDataJSChannel(context),
          },
          onWebViewCreated: (WebViewController webViewController) {
            _controller = webViewController;
          },
          onPageFinished: (_) async {
            // TODO
          },
        ),
      ),
    );
  }

I am using flutter 1.27.0-8.0.pre and webview_flutter: ^1.0.7. I have also tried to use the latest package version and 2.2.3 version of flutter and the issue persists. Any feedback is highly appreciated!

Nazarii Kahaniak
  • 461
  • 3
  • 11

1 Answers1

0

To solve this problem on iOS, simply add the following line of code to your info.plist file, which can be found under the runner folder of your iOS project for your flutter app.

<key>NSAppTransportSecurity</key>
 <dict>
 <key>NSAllowsArbitraryLoads</key><true/>
</dict>

Hope this solves the problem for you. for some reason the webview plugin blocks all taps until I added the line above to my plist.

Uchenna Nnodim
  • 458
  • 4
  • 11