Home > Web Front-end > JS Tutorial > body text

Comparative introduction between iOS and JS interaction methods

不言
Release: 2018-09-07 16:49:14
Original
1728 people have browsed it

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.

Interception protocol

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.

JavaScriptCore

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.

Third-party framework WebViewJavaScriptBridge

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

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!