fluttercommunity / flutter_webview_plugin

Community WebView Plugin - Allows Flutter to communicate with a native WebView.
https://pub.dev/packages/flutter_webview_plugin
Other
1.48k stars 932 forks source link

JavascriptChannel on iOS #712

Open kasyr opened 4 years ago

kasyr commented 4 years ago

I use JavascriptChannel to pass a string back to the app form webview. It works perfectly for Android but can't make it work on iOS? Is there anything specific I need to do to make it work?

class WebViewJavascriptChannel {
  static Set<JavascriptChannel> getChannel(Function(String) handler) {
    return [
      JavascriptChannel(
          name: 'JavascriptChannel',
          onMessageReceived: (JavascriptMessage javascriptMessage) {
            handler(javascriptMessage.message);
            print(javascriptMessage.message);
          }),
    ].toSet();
  }
}

Widget _getBankIDWebView(String url) {
    return WebviewScaffold(
      javascriptChannels:
          WebViewJavascriptChannel.getChannel(_updateString),
      url: url,
      withZoom: false,
      hidden: true,
      appBar: _getAppBar(),
    );
  }
malvinpratama commented 3 years ago

any update? i have same problem

shinriyo commented 1 year ago

Is it addJavascriptInterface in Kotlin?