Fun with cordova
Preface
It has been a long time since HTML5 and native code were used. Most of the people logging on are drooling. Those who actually work in this secret know the secrets. If HTML5 can completely replace native, what should we do with native? If HTML5 is completely unavailable, will so many awesome websites face each other? Therefore, webview is a control in android and ios, so you can use it properly. Webview is a control with a complete UI system and ecosystem. It is a lot of benefit to use it.
Okay, so the problem is coming. As a control, it is indispensable to interact with the native code. However, the common usage seems to be only used to open a webpage. This barely counts as "native code call js" and is still a one-time one. But how to play with "js call native? I once studied and wrote a tool https://github.com/fangj/WebViewJavascriptBridge on the basis of my predecessors, but it was not perfect. There is a ready-made cordova to use.
Before cordova. Let me talk about how webview interacts with native: