CN105718512A - Method for calling native language by using JS language in Ios system - Google Patents

Method for calling native language by using JS language in Ios system Download PDF

Info

Publication number
CN105718512A
CN105718512A CN201610020785.8A CN201610020785A CN105718512A CN 105718512 A CN105718512 A CN 105718512A CN 201610020785 A CN201610020785 A CN 201610020785A CN 105718512 A CN105718512 A CN 105718512A
Authority
CN
China
Prior art keywords
language
primary
call
ios system
webpage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610020785.8A
Other languages
Chinese (zh)
Inventor
黄少华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Cheerbright Technologies Co Ltd
Original Assignee
Beijing Cheerbright Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Cheerbright Technologies Co Ltd filed Critical Beijing Cheerbright Technologies Co Ltd
Priority to CN201610020785.8A priority Critical patent/CN105718512A/en
Publication of CN105718512A publication Critical patent/CN105718512A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/972Access to data in other repository systems, e.g. legacy data or dynamic Web page generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The present invention discloses a method for calling a native language by using a JS language in an Ios system, and relates to the technical field of computers. By means of a user-define URL (URL Scheme) link, the method implements a function of calling a native code in a webpage, and because the format of the URL link is standard, calling can be implemented only with the need for user-defining a parameter in the URL link and then parsing the parameter in the usage process, and therefore, the code is simple, and the implementation process of calling is convenient, simple and easy to be extended.

Description

A kind of method utilizing the primary language of JS language call in Ios system
Technical field
The present invention relates to field of computer technology, particularly relate to one and utilize JS language call former in Ios system The method of raw language.
Background technology
During Ios system uses UIWebView (webpage view), some content needs to call Protozoic Code promotes Consumer's Experience, and as logged in, pay, sharing, but JavaScript (being called for short JS) calls former Raw language, the most ready-made API, it is required to again develop.
At present, JS is called primary language and is mainly realized by following two method: a kind of method be complete from Definition agreement, this self-defining agreement is inconsistent with general url form, so, in use, Need to assemble or intercept, resolve field and the parameter of this non-standard url agreement, thus add the complexity of code Degree so that code is unfavorable for reading and understanding, mistake the most easily occurs;Second method is to use WebViewJavascriptBridge storehouse of increasing income realizes JS and calls primary language, although this method achieves The intermodulation between the primary code of JS and ios when using UIWebView, but be intended to add-on third party and increase income storehouse, Registration call method, so using more complicated.
Summary of the invention
It is an object of the invention to provide a kind of method utilizing the primary language of JS language call in Ios system, Thus solve foregoing problems present in prior art.
To achieve these goals, the technical solution used in the present invention is as follows:
A kind of method utilizing the primary language of JS language call in Ios system, comprises the steps:
S1, embeds self-defining URL link in webpage, it is thus achieved that containing the webpage of described URL link;
S2, represents the webpage containing described URL link in webpage view;
S3, receives user and asks the click of the described URL link on webpage;
S4, resolves described URL link, obtains the parameter of described URL link;
S5, according to the parameter obtained in S4, calls the primary language containing identical described parameter.
Preferably, in S1, described self-defining URL link includes the link of login feature, payment function Link and/or the link of sharing function.
Preferably, in S1, the described self-defining URL link of login feature, for:
< a href=" autohome: //cmdLogin?Callback=clickme_login " >,
Wherein,
Url scheme is autohome: //,
Url host is cmdLogin,
The parameter of transmission is: callback=clickme_login.
Preferably, S2 adopts and implements with the following method: added by the webpage containing described URL link obtained in S1 It is loaded in UIWebView container.
Preferably, S4 uses UIWebViewDelegate method, resolves described URL link, obtains described URL The parameter of link.
Further, further comprise the steps of: invoking web page JS method after S5, inform webpage, call Protozoic The function that code is write completes, and logic returns in webpage.
Preferably, after primary code function completes, primary language call UIWebView's StringByEvaluatingJavaScriptFromString function, the method for invoking web page JS language.
Further, the JS language of invoking web page in the primary language in Ios system is further comprised the steps of: after S5 Speech, it is achieved utilize the function of primary language call JS language.
Preferably, described realization utilizes the function of primary language call JS language, specifically, use UIWebV Iew-(NSString*) stringByEvaluatingJavaScriptFromString:(NSString*) script Method, it is achieved call JS language in the primary language in Ios system.
Preferably, described realization utilizes the function of primary language call JS language, including: in primary code Realize the increase of JS code, delete and/or revise.
The invention has the beneficial effects as follows: what the embodiment of the present invention provided utilizes JS language call in Ios system The method of primary language, is linked by self-defined URL (URL Scheme), it is achieved that call former in webpage The function of raw written in code, owing to the form of URL link is standard, in use, it is only necessary to right Parameter therein first carries out self-defined, then resolves, it is possible to realize calling, so, code is simple, The process that realizes called is convenient, simple, and easily extends.
Accompanying drawing explanation
Fig. 1 is the method stream utilizing the primary language of JS language call in Ios system that the embodiment of the present invention provides Journey schematic diagram.
Detailed description of the invention
In order to make the purpose of the present invention, technical scheme and advantage clearer, below in conjunction with accompanying drawing, to this Invention is further elaborated.Should be appreciated that detailed description of the invention described herein is only in order to solve Release the present invention, be not intended to limit the present invention.
As it is shown in figure 1, embodiments provide one to utilize the primary language of JS language call in Ios system Method, comprise the steps:
S1, embeds self-defining URL link in webpage, it is thus achieved that containing the webpage of described URL link;
S2, represents the webpage containing described URL link in webpage view;
S3, receives user and asks the click of the described URL link on webpage;
S4, resolves described URL link, obtains the parameter of described URL link;
S5, according to the parameter obtained in S4, calls the primary language containing identical described parameter.
In a preferred embodiment of the present invention, in S1, described self-defining URL link can include logging in The link of function, the link of payment function and/or the link of sharing function.
Wherein, in S1, the described self-defining URL link of login feature, Ke Yiwei:
< a href=" autohome: //cmdLogin?Callback=clickme_login " >,
Wherein,
Url scheme is autohome: //,
Url host is cmdLogin,
The parameter of transmission is: callback=clickme_login.
In the embodiment of the present invention, S2 can adopt with the following method implement: by S1 obtain containing described URL The webpage of link is loaded in UIWebView container.
In the embodiment of the present invention, S4 can use UIWebViewDelegate method, resolves described URL link, Obtain the parameter of described URL link.
In a preferred embodiment of the invention, step after S5, can also be included: invoking web page JS method, Informing webpage, call the function that primary code writes and complete, logic returns in webpage.
In a preferred embodiment of the invention, after primary code function completes, primary language call The stringByEvaluatingJavaScriptFromString function of UIWebView, the side of invoking web page JS language Method.
In a preferred embodiment of the invention, step can also be included after S5: former in Ios system The JS language of invoking web page in raw language, it is achieved utilize the function of primary language call JS language.
Wherein, described realization utilizes the function of primary language call JS language, is specifically as follows, and uses UIWe BView-(NSString*) stringByEvaluatingJavaScriptFromString:(NSString*) scri Pt method, it is achieved call JS language in the primary language in Ios system.
In a preferred embodiment of the invention, described realization utilizes the function of primary language call JS language, May include that and in primary code, realize the increase of JS code, delete and/or revise.
Wherein, in S1, described self-defining URL link includes the chain of the link of login feature, payment function Connect and/or the link of sharing function.
In S1, the described self-defining URL link of login feature, Ke Yiwei:
< a href=" autohome: //cmdLogin?Callback=clickme_login " >,
Wherein,
Url scheme is autohome: //,
Url host is cmdLogin,
The parameter of transmission is: callback=clickme_login.
In webpage, to call primary language, it is achieved primary login feature, payment function or sharing functionality, need The self-defining URL link for calling primary function is embedded in webpage.
The general format of URL is: scheme: //host:port/path?Query#fragment,
Self-defining URL link carries out self-defined according to the general format of URL, and wherein, url scheme can be certainly Definition name, url host can be with custom feature name, due to the parameter phase of self-defining parameter with primary language With, thus when user clicks on this self-defining URL link, then can be according to the primary language of these parameter calls Speech, it is achieved primary function.
In actual mechanical process, it is possible to use windows.location.href=" self-defining url " or Href=" self-defining url " realizes embedding self-defining URL link in webpage.During exploitation webpage, Can be with a newly-built project, the most newly-built helloworld.html.Call primary writing one below As a example by the link of login feature, illustrate how the self-defined URL link with primary language call function:
< a href=" autohome: //cmdLogin?Callback=clickme_login " >,
Wherein, url scheme:autohome: //,
Url host:cmdLogin,
The parameter of transmission: callback=clickme_login,
Callback parameter is callback method, after logining successfully, and js method clickme_login () of invoking web page, Logic returns in webpage.
By follow-up, the parameters such as the url scheme in self-defined URL link, url host, callback are carried out After parsing, it is possible to realize JS according to parameter and call primary login feature</a>.
The function of other primary code, again may be by self-defined URL link and realizes, the most primary Pay function and primary sharing functionality etc..
In the embodiment of the present invention, S2 can adopt with the following method implement: by S1 obtain containing described URL The webpage of link is loaded in UIWebView container.
By using said method, it is achieved webview view controller, display is containing described URL link Local page helloworld.html, so that after user logs in local page, it is possible to visible self-defining URL Link, and by clicking on this link, it is achieved primary login feature.
In the present embodiment, S4 can use UIWebViewDelegate method, resolves described URL link, Obtain the parameter of described URL link.
After self-defined URL link in user's webpage clicking, WebViewDelegate method is notified, Then the method is accepted commission, and resolves the parameter in self-defined URL link, acquisition url scheme: The data such as the parameter of url host and transmission.
Such as, if self-defined there is primary language call function URL link be:
< a href=" autohome: //cmdLogin?Callback=clickme_login " >,
Then, after resolving, the parameter of this link obtained is:
Url scheme:autohome: //,
Url host:cmdLogin,
The parameter of transmission: callback=clickme_login.
Then, according to these parameters, calling of primary code can be realized, complete primary login feature, make User can log according to the login feature that primary code realizes, thus brings preferably experience for user.
In the present embodiment, step after S5, can also be included: invoking web page JS method, inform webpage, call The function that primary code is write completes, and logic returns in webpage.
Primary function is realized in the method that the embodiment of the present invention provides, after logining successfully, invoking web page JS side Method, informs webpage, and primary login feature completes, during then logic returns webpage, so that webpage is held Row user other request operation.
In the embodiment of the present invention, the stringByEvaluatingJavaScriptFro of UIWebView can be used MString function, invoking web page JS method.
In the embodiment of the present invention, step can also be included after S5: in the primary language of webpage, call JS language Speech.
Use said method, it is possible to achieve mutually calling of primary language and JS language, thus improve further Consumer's Experience.
Concrete, can use UIWebView-(NSString*) stringByEvaluatingJavaScri PtFromString:(NSString*) script method, it is achieved call JS language in the primary language of webpage.
In a preferred embodiment of the present invention, described in the primary language of webpage, call JS language, including: In primary code, realize the increase of JS code, delete and/or revise.
By using technique scheme disclosed by the invention, obtain following beneficial effect: the present invention's Provide the benefit that: the side utilizing the primary language of JS language call in Ios system that the embodiment of the present invention provides Method, is linked by self-defined URL (URL Scheme), it is achieved that call the merit of primary written in code in webpage Can, owing to the form of URL link is standard, in use, it is only necessary to advanced to parameter therein Row is self-defined, then resolves, it is possible to realize calling, so, code is simple, and that calls realizes process Convenient, simple, and easily extend.
Each embodiment in this specification all uses the mode gone forward one by one to describe, and each embodiment stresses Being all the difference with other embodiments, between each embodiment, identical similar part sees mutually.
Those skilled in the art it should be understood that the sequential of the method step that above-described embodiment provides can be according to reality Situation carries out accommodation, it is possible to concurrently carry out according to practical situation.
All or part of step in the method that above-described embodiment relates to can instruct relevant hard by program Part completes, and described program can be stored in the storage medium that computer equipment can read, and is used for performing All or part of step described in the various embodiments described above method.Described computer equipment, such as: individual calculus Machine, server, the network equipment, intelligent mobile terminal, intelligent home device, wearable intelligent equipment, car Carry smart machine etc.;Described storage medium, such as: RAM, ROM, magnetic disc, tape, CD, sudden strain of a muscle Deposit, the storage of USB flash disk, portable hard drive, storage card, memory stick, the webserver, network cloud storage etc..
Finally, in addition it is also necessary to explanation, in this article, the relational terms of such as first and second or the like is only Only be used for by an entity or operation separate with another entity or operating space, and not necessarily require or Imply relation or the order that there is any this reality between these entities or operation.And, term " includes ", " comprise " or its any other variant is intended to comprising of nonexcludability, so that include a series of key element Process, method, commodity or equipment not only include those key elements, but also include being not expressly set out Other key elements, or also include the key element intrinsic for this process, method, commodity or equipment.? In the case of there is no more restriction, statement " including ... " key element limited, it is not excluded that including State and the process of key element, method, commodity or equipment there is also other identical element.
The above is only the preferred embodiment of the present invention, it is noted that for the common skill of the art For art personnel, under the premise without departing from the principles of the invention, it is also possible to make some improvements and modifications, this A little improvements and modifications also should regard protection scope of the present invention.

Claims (10)

1. the method utilizing the primary language of JS language call in Ios system, it is characterised in that include as Lower step:
S1, embeds self-defining URL link in webpage, it is thus achieved that containing the webpage of described URL link;
S2, represents the webpage containing described URL link in webpage view;
S3, receives user and asks the click of the described URL link on webpage;
S4, resolves described URL link, obtains the parameter of described URL link;
S5, according to the parameter obtained in S4, calls the primary language containing identical described parameter.
The method utilizing the primary language of JS language call in Ios system the most according to claim 1, its Being characterised by, in S1, described self-defining URL link includes the chain of the link of login feature, payment function Connect and/or the link of sharing function.
The method utilizing the primary language of JS language call in Ios system the most according to claim 2, its It is characterised by, in S1, the described self-defining URL link of login feature, for:
< a href=" autohome: //cmdLogin?Callback=clickme_login " >,
Wherein,
Url scheme is autohome: //,
Url host is cmdLogin,
The parameter of transmission is: callback=clickme_login.
The method utilizing the primary language of JS language call in Ios system the most according to claim 1, its Being characterised by, S2 adopts and implements with the following method: loaded by the webpage containing described URL link obtained in S1 Enter in UIWebView container.
The method utilizing the primary language of JS language call in Ios system the most according to claim 1, its Being characterised by, S4 uses UIWebViewDelegate method, resolves described URL link, obtains described URL The parameter of link.
The method utilizing the primary language of JS language call in Ios system the most according to claim 1, its It is characterised by, further comprises the steps of: invoking web page JS method after S5, inform webpage, call primary code and write Function complete, logic returns in webpage.
The method utilizing the primary language of JS language call in Ios system the most according to claim 6, its It is characterised by, after primary code function completes, primary language call UIWebView's StringByEvaluatingJavaScriptFromString function, the method for invoking web page JS language.
The method of the primary language of JS language call, its feature in Ios system the most according to claim 1 It is, after S5, further comprises the steps of: the JS language of invoking web page in the primary language in Ios system, it is achieved Utilize the function of primary language call JS language.
The method of the primary language of JS language call, its feature in Ios system the most according to claim 8 Being, described realization utilizes the function of primary language call JS language, specifically, use UIWebView's -(NSString*) stringByEvaluatingJavaScriptFromString:(NSString*) script method, real Now the primary language in Ios system calls JS language.
The method of the primary language of JS language call, its feature in Ios system the most according to claim 8 Being, described realization utilizes the function of primary language call JS language, including: in primary code, realize JS The increase of code, delete and/or revise.
CN201610020785.8A 2016-01-13 2016-01-13 Method for calling native language by using JS language in Ios system Pending CN105718512A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610020785.8A CN105718512A (en) 2016-01-13 2016-01-13 Method for calling native language by using JS language in Ios system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610020785.8A CN105718512A (en) 2016-01-13 2016-01-13 Method for calling native language by using JS language in Ios system

Publications (1)

Publication Number Publication Date
CN105718512A true CN105718512A (en) 2016-06-29

Family

ID=56147836

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610020785.8A Pending CN105718512A (en) 2016-01-13 2016-01-13 Method for calling native language by using JS language in Ios system

Country Status (1)

Country Link
CN (1) CN105718512A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106445531A (en) * 2016-09-28 2017-02-22 四川长虹电器股份有限公司 Cross-platform document reader based on mobile terminal and achieving method of cross-platform document reader
CN107341042A (en) * 2017-06-29 2017-11-10 武汉楚鼎信息技术有限公司 A kind of client based on webpage pop-up window embeds page exchange method and system
CN107562548A (en) * 2017-08-04 2018-01-09 北京趣拿软件科技有限公司 The method and apparatus for transmitting data
CN108334379A (en) * 2018-01-05 2018-07-27 北京明略软件系统有限公司 A kind of implementation method and realization device of page expansion function
CN110955430A (en) * 2018-09-26 2020-04-03 北京字节跳动网络技术有限公司 Application program native capability calling method and device and electronic equipment
CN111459685A (en) * 2019-01-18 2020-07-28 阿里巴巴集团控股有限公司 Communication method, device, equipment and readable medium of page end and native end

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104102537A (en) * 2013-04-07 2014-10-15 华为技术有限公司 Application calling method and user terminal
CN104301443A (en) * 2014-10-09 2015-01-21 百度在线网络技术(北京)有限公司 Method and system for calling end capacity ports on web page
CN104461575A (en) * 2014-12-26 2015-03-25 北京华电万通科技有限公司 Device and method for JavaScript native interface calling conducted by crossing mobile operating system platform
CN105138340A (en) * 2015-09-15 2015-12-09 北京齐尔布莱特科技有限公司 Interaction method and system for Native and Web pages
CN105204875A (en) * 2014-06-11 2015-12-30 腾讯科技(深圳)有限公司 Native function calling method and system of webpage

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104102537A (en) * 2013-04-07 2014-10-15 华为技术有限公司 Application calling method and user terminal
CN105204875A (en) * 2014-06-11 2015-12-30 腾讯科技(深圳)有限公司 Native function calling method and system of webpage
CN104301443A (en) * 2014-10-09 2015-01-21 百度在线网络技术(北京)有限公司 Method and system for calling end capacity ports on web page
CN104461575A (en) * 2014-12-26 2015-03-25 北京华电万通科技有限公司 Device and method for JavaScript native interface calling conducted by crossing mobile operating system platform
CN105138340A (en) * 2015-09-15 2015-12-09 北京齐尔布莱特科技有限公司 Interaction method and system for Native and Web pages

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106445531A (en) * 2016-09-28 2017-02-22 四川长虹电器股份有限公司 Cross-platform document reader based on mobile terminal and achieving method of cross-platform document reader
CN107341042A (en) * 2017-06-29 2017-11-10 武汉楚鼎信息技术有限公司 A kind of client based on webpage pop-up window embeds page exchange method and system
CN107562548A (en) * 2017-08-04 2018-01-09 北京趣拿软件科技有限公司 The method and apparatus for transmitting data
CN108334379A (en) * 2018-01-05 2018-07-27 北京明略软件系统有限公司 A kind of implementation method and realization device of page expansion function
CN110955430A (en) * 2018-09-26 2020-04-03 北京字节跳动网络技术有限公司 Application program native capability calling method and device and electronic equipment
CN111459685A (en) * 2019-01-18 2020-07-28 阿里巴巴集团控股有限公司 Communication method, device, equipment and readable medium of page end and native end

Similar Documents

Publication Publication Date Title
CN105718512A (en) Method for calling native language by using JS language in Ios system
CN104395884B (en) The data storage layer grade extended for Web page application program and browser
CN103731483A (en) Virtual file system based on cloud computing
CN104301443A (en) Method and system for calling end capacity ports on web page
CN105138340A (en) Interaction method and system for Native and Web pages
CN104980512B (en) It is a kind of to provide the method and apparatus of target object based on mobile application
CN105243407B (en) Read and write the method and device of smart card
TW201723897A (en) Method, device, and system for displaying information associated with a web page
CN104731869B (en) The page shows method and device
CN107770563A (en) A kind of barrage message treatment method and device
CN108829398B (en) Mobile terminal page interaction realization method and device
CN105051685A (en) System and method to enable web property access to a native application
CN107562548A (en) The method and apparatus for transmitting data
CN103064738A (en) Method and system for embedding local application program window into browser in Linux
CN105573733A (en) Communication method for browser and web front end and web front end and system
CN104468834A (en) Method and device for processing Cookie data and browser client side
CN105095220B (en) A kind of browser implementation method, terminal and virtualization agent device
CN106844364A (en) A kind of interconnected method of document information
Green Nature reserves of the Himalaya and the mountains of Central Asia
CN104050218A (en) Method and system for providing information to be displayed in user interface
CN110866202A (en) Front-end paging method and device and readable storage medium
CN110020343B (en) Method and device for determining webpage coding format
CN110795635A (en) Method and device for presenting books
CN111767498A (en) Method and device for realizing file information sharing
CN108984221B (en) Method and device for acquiring multi-platform user behavior logs

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20160629

RJ01 Rejection of invention patent application after publication