'Equivalent of callAsyncJavascript (IOS) for Android Webview
I'm working on a project which uses a webview on IOS and Android. I have some native methods which call some javascript methods with the evaluateJavascript webview method which is available from the IOS and Android.
Since I need to get the result of a JS promise, I'm using callAsyncJavascript on the IOS side.
The issue is I can't find any callAsyncJavascript on the Android side but I saw that it exists on Flutter.
Did someone have some knowledge about this? Is there some equivalent on Android? Or how does Flutter manage this internally?
Here is some code I'm using on IOS:
let script = """
return window.myJsMethod().then(({id}) => id);
"""
webView.callAsyncJavaScript(script, in: nil, in: .page, completionHandler: { result in
switch result {
case let .failure(error):
debugPrint("failure \(error)")
case let .success(result):
completion?(result as! String)
}
})
Solution 1:[1]
If there is some people interested, I found a way to implement callAsyncJavascript on Android by following the implementation of the flutter package flutter_inappwebview
You can find its code here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Thibault Capelli |
