We called a function in iOS from javascript i.e
var data = webkit.messageHandlers.callbackHandler.postMessage("Hello from JavaScript");
I want to assign returned value in data variable from called method in iOS.
iOS Code :
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
if(message.name == "callbackHandler") {
print("JavaScript is sending a message \(message.body)")
how to send data back??
}
}
can someone please tell me how to do it??
I know I can use evaluateJavascript to call back another method but due to some restriction I have to return result from same method.