As you may know, Android\'s WebView has a method named addJavascriptInterface() which imports an Android JAVA object to Javascript context.
addJavascriptInterface()
the question is,
I know this question is really old, but it seems that there is a better way to do it now with a WKWebView. See this answer: https://stackoverflow.com/a/37373745/1417922
WKWebView