JavaScript and iOS Communication solutions

Source: Internet
Author: User

After 1.5 years, the idea of a JavaScript and iOS communication was finally fulfilled (I don't know if anyone else has already done it).

Remember the early iOS embedded HTML to do the communication, it seems that the way to do is only iOS through the URL to intercept the page to send messages, but if the page frame dependency on the URL is relatively high then there will be problems, and frequent changes to Url,ios may not be able to intercept each URL.

A foreigner wrote a set of using this method to achieve the JS and iOS Communication Library, the basic principle is still the case. But seemingly did the optimization, the transformation of the URL is not in the webview, but the back end ran a webview specifically deal with the changes in the URL, I did not go into the study. This solves a part of the problem, but it doesn't sound very comfortable for me.

Later, in collaboration with iOS, I heard that JavaScript initiated the alert method that iOS can rewrite. It was a smart one, so why not rewrite the alert as a portal to receive the message? So as long as the agreed good message mode (such as alert a parameter for ordinary alert, multiple representative messages), so that JS can not directly communicate with iOS? iOS can only register multiple methods to process communication messages.

Because I basically did not dabble in iOS, so then find someone to confirm, but some said can not be achieved, some said there are problems, some also said can be achieved but ultimately did not give me the realization .... Then later iOS7 out, heard the original Alertview method changed, then feel fast give up.

Things shelved to today, finally we iOS department a manager listened to my idea, very agree to feel can try. I said iOS7 's concern, he said just changed a method. Not long after, I waited for 1.5 of the communication protocol finally realized! And the verification can, advantages and disadvantages I will not say, everyone think it knows! Special record down Memorial!

I regret that I didn't study iOS.

Related Article

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: 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.