Key Points Analysis of iOS hybrid apps and key points of ios hybrid apps

Source: Internet
Author: User

Key Points Analysis of iOS hybrid apps and key points of ios hybrid apps

Key Point Analysis of iOS hybrid apps-Implementation points of the local object method that can be injected with WebView on the Android platform

Beautiful Life of the sun and fire god (http://blog.csdn.net/opengl_es)

This article follows the "signature-non-commercial use-consistency" creation public agreement

Reprinted please keep this sentence: Sun huoshen's beautiful life-this blog focuses on Agile development and mobile and IOT device research: iOS, Android, Html5, Arduino, pcDuino, otherwise, this blog post is rejected or reprinted. Thank you for your cooperation.



For iOS and Android platforms, the UIWebView and WebView components of the respective smooth browser can easily call the JS scripts on the WebView page in local code.

Then, the local method called from JS is provided only by the WebView component of the Android platform, which is easy to understand. After all, the Android WebView component is implemented in Java, it is easy to inject some functions to reflection, but the specific implementation has not been confirmed by source code analysis.


For iOS, there is only one starting point, that is, through the page loading event of UIWebViewDelegate, the loading event in the page is obtained.

So how can we easily trigger a page loading event in the page so that we can intercept and respond to this HTML page event in the local proxy method?

This problem has abstracted the event trigger of the function caller and mapped to the Event Response Mechanism of the function caller.


1. Using the tag, the PhoneGap framework in earlier years was implemented in this way, but it felt constrained;

2. Add the input component and set it to the hidden state. By setting its onClick event, dynamically update its loaded link. This requires too many affiliated operations on the original page;

3. The principle of refresh the original page and trigger page loading when a page like img loads its src specified image twice;

In actual tests, it is found that the component is loaded serially only when the page is loaded for the first time. Even if the defer or async parameter is added, it cannot be triggered dynamically.

Then an open-source library is found, which uses the src of iframe to trigger loading. dynamically adding iframe to the page triggers the loading of the src link and can be captured locally, then remove the iframe immediately.


This open-source library can dynamically load all methods of iOS local objects to the window objects on the current page. You can directly call the methods of the corresponding objects on the page.


However, the real-time users of this library have incorrect understanding of the iOS method signature. Therefore, there is no good solution for the multi-parameter method.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.