Home > Article > Web Front-end > Comparative introduction between iOS and JS interaction methods
What are the differences between iOS and JS interaction methods? This article makes a simple comparison of the current interaction methods between iOS and JS. You can take a look if necessary.
Just a comparison of the currently existing interaction methods. There will be no implementation involved. If you need to know the specific usage. You can use Baidu or Google.
The interception protocol is the simplest interaction method. It intercepts directly on the Android side and iOS side, and can unify the web front-end code. The web front end takes parameters in the link. For example:
88gongxiang://loginFunc&name=xxx&pwd=123456. The scheme of intercepting the url is equal to 88gongxiang. It is intercepted by Native and processed by itself.
After iOS7, Apple launched the JavaScriptCore framework, which makes it very convenient for web pages to interact with local native applications, and using this framework can make Android and iOS relatively unified. The web front-end can adapt to the two client platforms by writing a set of codes, thereby reducing the workload of the web front-end.
WebViewJavaScriptBridge is currently a popular JS interactive framework for iOS. WebViewJavaScriptBridge is encapsulated based on the interception protocol. Supports both UIWebview and WKWebview. However, the corresponding code needs to be embedded in the web front-end. At the same time, the web front-end code needs to comply with the regulations of WebViewJavaScriptBridge and cannot be unified with Android.
WKWebview is a browser component provided after iOS 8. When JS interacts with WKWebview, JS calls window.webkit.messageHandlers to send messages and call Native. It is impossible to unify the code on the web side.
The above interaction methods are determined according to different needs. The following can be used as a reference:
If the web side is short of manpower or wants to perform unified processing, JavaScriptCore and interception can be used method of agreement. If it is a simple interactive method, just use the interception protocol directly.
The third-party frameworks WebViewJavaScriptBridge and WKWebview require the cooperation of the web side.
Just a comparison of the currently existing interaction methods. There will be no implementation involved. If you need to know the specific usage. You can use Baidu or Google.
Related recommendations:
Interaction between native iOS and js
Detailed explanation and implementation code of interaction between javascript and IOS ObjectC
The above is the detailed content of Comparative introduction between iOS and JS interaction methods. For more information, please follow other related articles on the PHP Chinese website!