flutter_webview_plugin icon indicating copy to clipboard operation
flutter_webview_plugin copied to clipboard

Implement onJSAlert, onJSConfirm, onJSPrompt interface

Open j796160836 opened this issue 4 years ago • 3 comments

Related issue: #376, enhanced Pull request by: #522.

Instead of implement native code, I advocate it handling that flutter side. I extract both iOS and Android native callback into three functions.

Native callback

Android iOS
Alert public boolean onJsAlert(WebView view, String url, String message, final JsResult result) webView(_:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)
Confirm public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) webView(_:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)
Prompt public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) webView(_:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)

Flutter callback

Flutter
Alert flutterWebViewPlugin.onJSAlert = (alert) async { };
Confirm flutterWebViewPlugin.onJSConfirm = (confirm) async { };
Prompt flutterWebViewPlugin.onJSPrompt = (prompt) async { };

Also, I filled up the example.

j796160836 avatar Jan 30 '20 10:01 j796160836

Thank you for PR and sorry for long review time, I am quite busy these days. I will review this asap, although code doesn't work for me for example project.

charafau avatar Apr 07 '20 14:04 charafau

@j796160836 conflicted

shinriyo avatar Sep 29 '20 09:09 shinriyo

Any updates on this feature?

jfacoustic avatar Dec 12 '22 22:12 jfacoustic