Tag: Port lock based on ASC core IDG a dot Val
Http://www.cocoachina.com/ios/20160127/15105.html
Recently, the company's operations to engage in a blind activity, its activities to provide data support services, the Web front-end in the public account as the main operating positions, and iOS, Android to provide the corresponding portals and pages to match. An activity that uses the various end of the program ape. And in the face of technology is mainly related to Web-side and server-side interaction, web front-end and iOS, Android interaction. I as an IOS developer, today chat about the Web, IOS, Android three-terminal interaction, in fact, the white point is the method of mutual invocation. The main explanation here is iOS. Android will slightly mention it for reference only.
The logical diagram of this article
Figure 0-0 The logical diagram of this article
Overview
iOS native Apps and Web pages interact roughly in these ways iOS7 after the JavaScriptCore, intercept protocol, third-party framework Webviewjavascriptbridge, IOS8 after the wkwebview here mainly to explain the JavaScriptCore and interception protocol two ways. Webviewjavascriptbridge is an encapsulation based on the interception protocol. The study cost is relatively javascriptcore higher, the use also is inferior javascriptcore convenient This article does not narrate. Wkwebview is iOS8 after the launch, has not become mainstream use, so this article does not do a detailed description.
Ios
The iOS side writes code based on the method name defined by the front end, but sometimes the Web front end lets us define it, but when we define it, he's going to change it again. So when it comes to three-terminal interaction, it's best to have the Web front-end define the method name, and iOS and Android write code based on the Web front-end definition. JavaScriptCore in the Web page call native application method can be used delegate or block two methods, this article to be explained by delegate.
JavaScriptCore Classes and protocols:
Jscontext: Provides a context for JavaScript to run
Bridges of Jsvalue:javascript and objective-c data and methods
Jsmanagedvalue: Classes for managing data and methods
Jsvirtualmachine: Handling thread-related, using less
Jsexport: This is an agreement that, if you interact with a protocol, your own defined protocol must comply with this Protocol
Objective-c the things that interact with JavaScript