Method and related apparatus for native application to communicate with web page

By automatically generating business code for native applications through the system's common communication protocol, the problem of inconsistent configuration parameters under different operating systems is solved, and unified communication between native applications and web pages is achieved, reducing adaptation costs and workload and improving R&D efficiency.

CN116662695BActive Publication Date: 2026-06-23TENCENT TECH (BEIJING) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT TECH (BEIJING) CO LTD
Filing Date
2022-02-17
Publication Date
2026-06-23

Smart Images

  • Figure CN116662695B_ABST
    Figure CN116662695B_ABST
Patent Text Reader

Abstract

The application provides a method and related device for communication between a native application and a webpage, and relates to the technical field of computers.In the application, when the webpage determines that a target function of the native application needs to be called, the function calling information is sent to the native application; the webpage receives the function callback result returned by the native application, the function callback result is determined and returned by the target configuration parameter defined by the corresponding business code of the native application under the corresponding operating system system, and the target configuration parameter defined by the business code under any operating system system is determined based on the system general communication protocol between the native application and the webpage.No matter what kind of operating system the native application runs under, the target configuration parameter defined by each business code is determined based on the system general communication protocol, that is, the configuration parameters defined in each business code are consistent, the workload of adaptation is reduced, and the adaptation cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method and related apparatus for communication between a native application and a web page. Background Technology

[0002] With the development of network technology, more and more client applications are appearing in the public eye. These clients combine native and web page functions, that is, a lightweight browser is embedded in the native application to support the World Wide Web page function; and the clients are supported by various operating systems.

[0003] When the web page functionality is enabled on a currently running client, communication between the native application and the web page will be based on business logic code. However, the configuration parameters defined in the business logic code of the native application differ across operating systems. In this case, different adaptation code needs to be developed for the web page to achieve business logic communication.

[0004] It is evident that when configuration parameters defined in the business code of the same native application are inconsistent across different operating systems, it will increase the workload and cost of adapting web pages, and further reduce development efficiency. Summary of the Invention

[0005] This application provides a method and related apparatus for communication between a native application and a web page, in order to avoid inconsistencies in the configuration parameters defined in the business code of the same native application under different operating systems, thereby reducing the workload of web page adaptation and lowering adaptation costs.

[0006] In a first aspect, embodiments of this application provide a method for communication between a native application and a web page, applied to a web page, the method comprising:

[0007] When it is determined that a target function of the native application needs to be invoked, the function invocation information is sent to the native application;

[0008] Receive the function callback result returned by the native application. The function callback result is determined and returned by the native application through the target configuration parameters defined in the corresponding business code under the corresponding operating system standard. The target configuration parameters defined in the business code under any operating system standard are determined based on the system general communication protocol between the native application and the web page.

[0009] Secondly, embodiments of this application provide a method for communication between a native application and a web page, applicable to native applications running under any operating system standard, the method comprising:

[0010] Receive function call information sent from the web page;

[0011] Under the current operating system standard, the function callback result corresponding to the function call information is determined by the target configuration parameters defined in the business code, and the function callback result is returned to the web page; the target configuration parameters defined in the business code are determined based on the system's common communication protocol between the native application and the web page.

[0012] Thirdly, embodiments of this application provide a device for communication between a native application and a web page, applied to a web page, the device comprising:

[0013] The sending unit is used to send function call information to the native application when it is determined that a target function of the native application needs to be called.

[0014] The first receiving unit is used to receive the function callback result returned by the native application. The function callback result is determined and returned by the native application under the corresponding operating system standard through the target configuration parameters defined in the corresponding business code. The target configuration parameters defined in the business code under any operating system standard are determined based on the system general communication protocol between the native application and the web page.

[0015] In one optional implementation, the first receiving unit is specifically used for:

[0016] The system receives function callback results returned by the native application through a defined generic interface; the generic interface is adapted to the interface callback value obtained from the system's general communication protocol.

[0017] Fourthly, embodiments of this application provide a method for communication between a native application and a web page, applicable to native applications running on any operating system standard. The apparatus includes:

[0018] The second receiving unit is used to receive function call information sent by the web page;

[0019] The return unit is used, under the current operating system standard, to determine the function callback result corresponding to the function call information through the target configuration parameters defined in the business code, and to return the function callback result to the web page; wherein, the target configuration parameters defined in the business code are determined based on the system's common communication protocol between the native application and the web page.

[0020] In one alternative implementation, the business code is determined as follows:

[0021] An abstract syntax tree scan analysis is performed on the system's general communication protocol to generate a syntax tree containing the target configuration parameters;

[0022] By using an iterator, the syntax tree is traversed to generate the corresponding business code for the native application under various operating system standards.

[0023] In one optional implementation, an abstract syntax tree scan analysis is performed on the system's general communication protocol to generate a syntax tree containing the target configuration parameters, including:

[0024] The lexical analyzer, based on the defined lexical rules, converts the system's general communication protocol into a sequence of identifiers, where the identifier sequence contains the target configuration parameters.

[0025] The parser transforms a sequence of identifiers into a syntax tree containing target configuration parameters, based on defined syntax rules.

[0026] In one optional implementation, after performing abstract syntax tree scanning analysis on the system's general communication protocol to generate a syntax tree containing the target configuration parameters, the method further includes:

[0027] The syntax tree is re-edited to obtain a target syntax tree containing the target configuration parameters, wherein the number of levels in the target syntax tree is less than the number of levels in the syntax tree.

[0028] In one alternative implementation, an iterator is used to traverse the syntax tree and generate the corresponding business code for the native application under various operating system standards, including:

[0029] If the native application runs on the first operating system, the syntax tree is traversed through the first iterator supported by the first operating system to generate business code in Java code format;

[0030] If the native application runs on a second operating system, the syntax tree is traversed using the second iterator supported by the second operating system to generate business code in Objective-C format.

[0031] In one optional implementation, after generating the corresponding business code for the native application under various operating system standards based on the syntax tree, the method further includes:

[0032] Each generated business code is submitted to its respective information management database.

[0033] In one optional implementation, the target configuration parameters include: the calling method, request parameters, and interface callback values;

[0034] The return unit is specifically used to: determine the function callback result based on the calling method and request parameters defined in the business code, and return the function callback result to the web page through the interface corresponding to the interface callback value.

[0035] Fifthly, embodiments of this application provide a device for communication between a native application and a web page, comprising: a memory and a processor, wherein the memory is used to store computer instructions; and the processor is used to execute the computer instructions to implement the steps of the method for communication between a native application and a web page provided in embodiments of this application.

[0036] Sixthly, embodiments of this application provide a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the method for communication between a native application and a web page provided in embodiments of this application.

[0037] In a seventh aspect, embodiments of this application provide a computer program product, which includes computer instructions stored in a computer-readable storage medium; when the processor of an electronic device reads the computer instructions from the computer-readable storage medium, the processor executes the computer instructions, causing the electronic device to perform the steps of the method for communicating between a native application and a web page provided in embodiments of this application.

[0038] The beneficial effects of this application are as follows:

[0039] In the communication scheme between a native application and a web page provided in this application embodiment, when the web page determines that it needs to call a target function of the native application, it sends function call information to the native application, which can be any application running on any operating system. The web page receives the function callback result returned by the native application. The function callback result is determined and returned by the native application under the corresponding operating system by the target configuration parameters defined in the corresponding business code. The target configuration parameters defined in any business code are determined based on the system's common communication protocol between the native application and the web page. In this application embodiment, regardless of the operating system on which the native application runs, the target configuration parameters defined in each business code corresponding to the native application are determined based on the system's common communication protocol. That is, the configuration parameters defined in each business code are consistent, avoiding the situation where the configuration parameters defined in different business codes of the same native application are inconsistent under different operating systems, further reducing the workload of web page adaptation and lowering adaptation costs.

[0040] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0041] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0042] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application;

[0043] Figure 2 A flowchart illustrating a method for generating business code, as provided in this application embodiment;

[0044] Figure 3 A schematic diagram illustrating the generation of business code as provided in an embodiment of this application;

[0045] Figure 4 A schematic diagram of a syntax tree provided for an embodiment of this application;

[0046] Figure 5 A schematic diagram of another syntax tree provided for an embodiment of this application;

[0047] Figure 6 This is a schematic diagram illustrating how each generated business code is submitted to a corresponding information management database, as provided in an embodiment of this application.

[0048] Figure 7 An architecture diagram illustrating a specific implementation method for generating business code, provided in this application embodiment;

[0049] Figure 8 This application provides a tool for automatically generating business code.

[0050] Figure 9 A flowchart illustrating a specific implementation method of a native application and a web page provided in this application embodiment;

[0051] Figure 10 A flowchart illustrating a method for communication between a native application and a web page, provided in an embodiment of this application;

[0052] Figure 11 A flowchart illustrating another method for communication between a native application and a web page, as provided in this application embodiment;

[0053] Figure 12 A structural diagram of a device for communication between a native application and a web page is provided in an embodiment of this application;

[0054] Figure 13 Another device structure diagram for communication between a native application and a web page provided in the embodiments of this application;

[0055] Figure 14 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0056] To make the objectives, technical solutions, and beneficial effects of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0057] To facilitate a better understanding of the technical solutions of this application by those skilled in the art, some of the concepts involved in this application are introduced below.

[0058] Native application: An application designed to run in a terminal device environment (machine language and operating system).

[0059] Web page: A web page is a page in a web application. It is usually a basic element of a web browser and is used to display content such as images and text.

[0060] Communication protocol: This refers to the rules for data conversion. When the code runs, it needs to receive and send data. The protocol data packet specifies the data conversion format, such as data length, number system conversion, and equivalent. The communication protocol can be custom-defined. For example, the communication protocol corresponding to the IO interface is responsible for data format conversion, while the communication protocol corresponding to the process interface is responsible for data processing, including floating-point arithmetic rules.

[0061] Abstract Syntax Tree (AST): In computer science, an AST is an abstract representation of the syntax structure of source code. It represents the syntax structure of a programming language in a tree-like format, where each node represents a structure within the source code. It's called "abstract" because it doesn't represent every detail of the actual syntax. For example, nested parentheses are implicit in the tree structure and not presented as nodes; while conditional jump statements like `if-condition-then` can be represented using nodes with two branches.

[0062] Parser: Usually appears as a component of a compiler or interpreter. Its role is to perform syntax checking and build a data structure composed of input words (usually a hierarchical data structure such as a parse tree or abstract syntax tree).

[0063] A parser typically uses a separate lexical analyzer to separate individual "words" from the input character stream and uses the word stream as its input.

[0064] The first and second operating systems are computer programs developed using different computer languages ​​to manage computer hardware and software resources. Furthermore, applications running on the application layer of the first operating system are written in the programming language corresponding to the first operating system; similarly, applications running on the application layer of the second operating system are written in the programming language corresponding to the second operating system.

[0065] For example: The first operating system is the Android operating system, which is developed using Java as the development tool. Therefore, the applications on the application layer of the Android operating system are written in Java, and Java is used as the development language. The second operating system is the iOS operating system, which is developed using Objective-C as the development tool. Therefore, the applications on the application layer of the iOS operating system are written in Objective-C, and Objective-C is used as the development language.

[0066] It should be noted that the first operating system can be any operating system developed using Java, including Android and Linux; similarly, the second operating system can be any operating system developed using Objective-C, including iOS and macOS; and the use of Java and Objective-C to develop operating systems is only an example, and the embodiments of this application can also be applied to operating systems developed using other computer languages.

[0067] Java is an object-oriented programming language that not only absorbs the advantages of C++ but also eliminates difficult-to-understand concepts such as multiple inheritance and pointers. Therefore, Java is both powerful and easy to use. Objective-C is a wrapper around the C language, adding an object-oriented syntax layer on top of C. It is fully compatible with C, and C, and even C++, code can be used within Objective-C code.

[0068] The word “exemplary” as used below means “serving as an example, embodiment, or illustration.” Any embodiment illustrated as an “exemplary” need not be construed as superior to or better than other embodiments.

[0069] The terms "first" and "second" used in this document are for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated. Therefore, features defined as "first" or "second" may explicitly or implicitly include one or more features. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0070] The design concept of the embodiments of this application is briefly introduced below:

[0071] With the development of network technology, more and more client applications are appearing in the public eye. These clients combine native functionality with web page functionality, that is, embedding a lightweight browser within a native application to support World Wide Web page functionality. Since native applications can run directly on any operating system—for example, application A developed for Android runs directly on Android, or application A developed for iOS runs directly on iOS—this client has gained support from multiple operating systems.

[0072] When enabling web page functionality in a currently running client, the web page's permissions are restricted, requiring it to communicate with the native application to obtain certain functional information before implementing the corresponding functions on the client. Therefore, a communication bridge (Jsbridge) needs to be created between the native application and the web page to facilitate communication between them. Business logic code is required for this communication between the native application and the web page.

[0073] Currently, the configuration parameters defined in the business code for the same native application differ across operating systems. Therefore, if a web page needs to be adapted to different operating systems, different adaptation code needs to be developed for the web page to achieve business logic communication. For example, Android and iOS video clients each define their own configuration parameters in their respective business code; in this case, web page adaptation work needs to be performed separately for Android and iOS video clients to achieve business logic communication.

[0074] It is evident that when configuration parameters defined in the business code of the same native application are inconsistent across different operating systems, it will increase the workload and cost of adapting web pages, and further reduce development efficiency.

[0075] In view of this, embodiments of this application provide a scheme for generating business code, and a scheme for native applications to execute business code and communicate with web pages.

[0076] In this embodiment, the system-wide communication protocol between the defined native application and the web page is parsed to automatically generate business code corresponding to the native application running on the first operating system and the native application running on the second operating system. At this point, regardless of whether the business code is running on the first or second operating system, the configuration parameters in the business code are determined based on the system-wide communication protocol. This ensures that the configuration parameters defined in the various business codes corresponding to the same native application are consistent across different operating systems. Therefore, when the web page communicates with the native application, there is no need for separate adaptation for the native application running on the first and second operating systems. This achieves a unified communication solution between the same native application running on different operating systems and the web page, reducing the workload and cost of web page adaptation.

[0077] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.

[0078] Please refer to Figure 1 , Figure 1 This is a schematic diagram of an application scenario according to an embodiment of this application. The application scenario includes multiple terminal devices 110 and a server 120, and the terminal devices 110 and the server 120 can communicate with each other through a communication network.

[0079] In one alternative implementation, the communication network can be a wired network or a wireless network. Therefore, the terminal device 110 and the server 120 can be connected directly or indirectly via wired or wireless communication. For example, the terminal device 110 can be indirectly connected to the server 120 via a wireless access point, or the terminal device 110 can be directly connected to the server 120 via the Internet; this application does not impose any limitations on this.

[0080] In this application embodiment, the terminal device 110 includes, but is not limited to, mobile phones, tablets, laptops, desktop computers, e-book readers, smart voice interaction devices, smart home appliances, vehicle terminals, and other devices; various clients can be installed on the terminal device, which can be applications (such as browsers, game software, etc.), pages, mini-programs, or applications that support native functions and web functions;

[0081] Server 120 is the backend server corresponding to the client. Server 120 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.

[0082] It should be noted that the native application and web page methods in the embodiments of this application can be executed by an electronic device, which can be a terminal device 110, that is, the method can be executed by the terminal device 110.

[0083] It should be noted that, Figure 1 The examples shown are merely illustrative; in reality, the number of terminal devices 110 and servers 120 is not limited and is not specifically limited in this embodiment.

[0084] In this embodiment of the application, when there are multiple servers 120, the multiple servers 120 can form a blockchain, and the server 120 is a node on the blockchain; as disclosed in the method for viewing application data in this embodiment of the application, the application data involved can be stored on the blockchain.

[0085] Based on the above application scenarios, the following describes a method for communication between a native application and a web page, provided by an exemplary embodiment of this application, in conjunction with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of this application, and the implementation methods of this application are not limited in any way. Furthermore, the embodiments of this application can be applied to various client scenarios involving communication between a native application and a web page, such as cloud technology, artificial intelligence, smart transportation, and assisted driving.

[0086] When native applications and web pages communicate, native applications running on different operating systems developed using different computer languages ​​each have a corresponding business code, and the configuration parameters defined in each business code are inconsistent. For example, native application A running on the Android operating system corresponds to a business code A, and native application A running on the iOS operating system corresponds to a business code B, and the configuration parameters defined in business code A and business code B are inconsistent.

[0087] At this point, the web page needs to be adapted to native applications under various operating system standards; for example, the web page needs to be adapted to native application A running on the Android operating system, and the web page also needs to be adapted to native application A running on the iOS operating system.

[0088] Therefore, this application addresses the issue of increased workload and cost in web page adaptation when native applications running on different operating system standards communicate with web pages. This is because each native application has its own corresponding business code, and the configuration parameters defined in each business code are inconsistent. The application proposes a method to generate corresponding business code for the native application, ensuring that the configuration parameters defined in the business code of each native application running on different operating system standards are consistent. This allows the web page to uniformly adapt to native applications running on different operating system standards during communication between the native application and the web page, reducing the workload and cost of web page adaptation and further improving development efficiency.

[0089] The following examples illustrate the schemes for generating business code corresponding to native applications and the schemes for communication between native applications and web pages.

[0090] Example 1: Generate the business code corresponding to the native application.

[0091] Please refer to Figure 2 , Figure 2 An exemplary flowchart of a method for generating business code according to an embodiment of this application is provided, including the following steps:

[0092] Step S200: Obtain the system's common communication protocol between the native application and the web page.

[0093] In this embodiment, the communication protocol between native applications running under different operating system standards and web pages is a single communication protocol. For example, the communication protocol between native applications running under the first operating system standard and web pages is the same as the communication protocol between native applications running under the second operating system standard, which is the Jsbridge protocol. Therefore, in this embodiment, the Jsbridge protocol is referred to as the system general communication protocol.

[0094] Please refer to Figure 3 , Figure 3 An exemplary diagram illustrating the generation of business code in an embodiment of this application is provided. The Jsbridge protocol between the native application and the web page is obtained from a core database used to store common communication protocols of the storage system.

[0095] In one optional implementation, the system's general communication protocol includes module names, calling methods, request parameters, and interface callback values, etc.; taking a video client as an example, the format of the Jsbridge protocol between the native application and the web page in this video client is as follows:

[0096]

[0097] In this embodiment of the application, after obtaining the system's general communication protocol, the system's general communication protocol is parsed to automatically generate the business code corresponding to the native applications running under each operating system standard; for example, the business code corresponding to the native application running under the first operating system standard is automatically generated, and the business code corresponding to the native application running under the second operating system standard is automatically generated.

[0098] When generating business code, the system's general communication protocol is first parsed to obtain the syntax tree corresponding to the system's general communication protocol, and then the business code is automatically generated based on the syntax tree; see the description of steps S201 to S202 for details.

[0099] Step S201: Perform abstract syntax tree scanning analysis on the system's general communication protocol to generate a syntax tree containing the target configuration parameters.

[0100] Please refer to Figure 3 It retrieves the core parser from the parser database used to store the core parser, and then parses out the corresponding syntax tree using the lexical analyzer and syntax analyzer defined in the core parser.

[0101] In one alternative implementation, a lexical analyzer, based on defined lexical rules, converts the system's general communication protocol into a sequence of tokens, wherein the token sequence contains target configuration parameters.

[0102] The lexical analyzer can be a Lexical Analyzer, abbreviated as lex. The lex tool generates a word recognition program based on the requirements of the lexical rule specification, which then identifies each word in the input text. It generally consists of a <definition section>, a <rule section>, and a <user subroutine section>. The rule section is mandatory, while the definition and user subroutine sections are optional. When analyzing the lexical structure, the lex tool reads each character one by one, performing rule matching from top to bottom.

[0103] The format of the identifier sequence corresponding to the general communication protocol of the above systems is as follows:

[0104] Original statement:

[0105] String type; / / Login method

[0106] After the character parser (tokenize) parses the data:

[0107] STRING VARIABLE SEMICOLON COMMENT

[0108] String –> STRING

[0109] Version –>VARIABLE

[0110] ;–>SEMICOLON

[0111] / / Version number –> COMMENT

[0112] It should be noted that the character parser is used to find the next identifier in the system's general communication protocol.

[0113] The parser transforms a sequence of identifiers into a syntax tree containing target configuration parameters, based on defined syntax rules.

[0114] In this embodiment of the application, the parser is Yet Another Compiler Compiler, abbreviated as yacc.

[0115] In this embodiment of the application, the defined syntax rules are as follows:

[0116] Define exprNode (external node):

[0117] STRING VARIABLE SEMICOLON COMMENT;

[0118] Define paramNode (secondary node):

[0119] (request||callback)L_BRACE[exprNode]R_BRACE;

[0120] Define serviceNode (service node)

[0121] Service L_BRACE[exprNode]R_BRACE.

[0122] Using a parser, the identifier sequence is parsed according to the syntax rules defined above, ultimately generating a syntax tree containing the target configuration parameters. Please refer to [link / reference]. Figure 4 , Figure 4 A schematic diagram of a syntax tree is provided as an example in an embodiment of this application.

[0123] Step S202: Using an iterator, traverse the syntax tree to generate the corresponding business code for the native application under each operating system standard.

[0124] In this embodiment of the application, after obtaining the syntax tree, the syntax tree is traversed through an iterator to generate the business code corresponding to the native application under each operating system standard, wherein the iterator can be an Enumerator.

[0125] Because native applications run on different operating system standards, and each operating system standard supports different programming languages, different iterators are used to generate the corresponding business code for each operating system standard.

[0126] In one alternative implementation, when the native application is running on the first operating system, the syntax tree is traversed through the first iterator supported by the first operating system to generate business code in Java code format.

[0127] When the native application runs on a second operating system, it traverses the syntax tree using a second iterator supported by the second operating system to generate business code in Objective-C format.

[0128] The first operating system and the second operating system are operating systems developed using different computer languages. The first operating system is developed using the Java language, and the second operating system is developed using the Objective-C language.

[0129] Taking the generation of business code in Objective-C format as an example, the format of the business code generated based on the above-mentioned system's general communication protocol is as follows:

[0130]

[0131]

[0132] To improve the speed of generating business code, in this embodiment of the application, after generating a syntax tree containing target configuration parameters, the syntax tree is re-edited to obtain a target syntax tree containing target configuration parameters. The target syntax tree contains the same node information as the syntax tree, but the number of levels in the target syntax tree is less than the number of levels in the syntax tree.

[0133] Please refer to Figure 5 , Figure 5 An exemplary schematic diagram of another syntax tree in this application embodiment is provided. Therefore, when generating business code by traversing the target syntax tree through an iterator, the number of levels traversed by the iterator is reduced, thereby improving the speed of generating business code.

[0134] In this embodiment of the application, after generating the corresponding business code for the native application under each operating system standard, the generated business code is submitted to the corresponding information management database.

[0135] Please refer to Figure 3 After generating Java code for native applications running on the first operating system, the Java code is submitted to the information management database (Jsbridge_Android) corresponding to the first operating system for storage; and after generating Objective-C code for native applications running on the second operating system, the Objective-C code is submitted to the information management database (Jsbridge_iOS) corresponding to the second operating system for storage.

[0136] It should be noted that the embodiments involved in this application are illustrated using Android as the first operating system and iOS as the second operating system.

[0137] In this embodiment, after generating the business code, an automated pipeline is triggered to generate a MapReduce commit. The business code is then merged into the information management databases of the first and second operating systems via the MapReduce commit. Please refer to [link / reference needed]. Figure 6 , Figure 6 This application provides an exemplary embodiment of a method for submitting the generated business codes to the corresponding information management database, thereby significantly improving the development efficiency and communication costs of native applications and web pages.

[0138] Please refer to Figure 7 , Figure 7 An exemplary architecture diagram of a specific implementation method for generating business code is provided in this application.

[0139] like Figure 7 As shown, when native applications and web pages need to add communication functionality, a system-wide communication protocol (Jsbridge protocol) is agreed upon. The Jsbridge protocol includes module names, method names, request parameters, and interface callbacks. After the system-wide communication protocol is updated, a Python script automatically parses and generates business code in Java format for the native application running on the first operating system (example shown in the diagram), and generates business code in Objective-C format for the native application running on the second operating system (example shown in the diagram).

[0140] After generating Java and Objective-C code, an automated pipeline is triggered to generate MR submissions, which then submit the generated Java and Objective-C code to the information management databases of the first and second operating systems.

[0141] To generate business code corresponding to native applications, this application provides a tool for automatically generating business code. Please refer to... Figure 8 , Figure 8 An exemplary schematic diagram of the interface of a tool for automatically generating business code is provided in an embodiment of this application.

[0142] It should be noted that, in this embodiment of the application, the system general communication protocol stored in the core database used to store the system general communication protocol will also be detected. When a change in the system general communication protocol is detected, the business code corresponding to the native application will be re-determined according to the changed system general communication protocol. The process of determining the business code is similar to... Figure 2 The method described is consistent with that.

[0143] In this embodiment, regardless of the operating system on which the native application runs, the target configuration parameters defined by each business code corresponding to the native application are determined based on the system's general communication protocol. That is, the configuration parameters defined in each business code are consistent, avoiding the situation where the configuration parameters defined in each business code of the same native application are inconsistent under different operating systems.

[0144] Example 2: A method for communication between native applications and web pages.

[0145] Please refer to Figure 9 , Figure 9 An exemplary flowchart of a specific implementation method of a native application and a web page is provided in this application embodiment, the method including:

[0146] In step S900, when the web page determines that it needs to call the target function of the native application, it sends the function call information to the native application.

[0147] In this embodiment of the application, the Web page and the native application are two types of functions supported in the same client. When the Web page is launched in the client, in order to implement the Web page functions and display relevant information in the client, the Web page needs to call the functions of the native application.

[0148] Therefore, when a web page runs on a client and determines that it needs to call a target function of a native application, it sends a function call message to the native application; where the native application is an application running on any operating system.

[0149] Step S901: The native application receives the function call information sent by the web page.

[0150] In step S902, the native application, under the current operating system standard, determines the function callback result corresponding to the function call information through the target configuration parameters defined in the business code.

[0151] In step S903, the native application returns the function callback result to the web page.

[0152] In one alternative implementation, the target configuration parameters defined in the business code are determined based on the system's common communication protocol between the native application and the web page, and the target configuration parameters include: the calling method, request parameters, and interface callback values;

[0153] When determining the function callback result corresponding to the function call information through the target configuration parameters defined in the business code, and returning the function callback result to the web page: the function callback result is determined through the call method and request parameters defined in the business code, and the function callback result is returned to the web page through the interface corresponding to the interface callback value defined in the business code.

[0154] In step S904, the web page receives the function callback result returned by the native application through the defined general interface.

[0155] To ensure that web pages are compatible with native applications under various operating system standards, reduce the workload and cost of adaptation, this application proposes a general interface for web pages. This general interface is adapted to the interface callback values ​​obtained from the system's general communication protocol.

[0156] Therefore, web pages can receive function callback results returned by native applications under various operating system standards through a common interface.

[0157] Taking a video playback client as an example, video playback clients support both native functions and page functions.

[0158] The video playback client's display interface includes a search box, which corresponds to a browser. Therefore, this video playback client supports page functionality. When the search information is entered into the search box, a web page is launched. When the web page runs and displays the corresponding search information, due to the limited permissions of the web page, it requires the support of the native application. Therefore, the web page communicates with the native application, sending function call information to the native application and receiving the function callback results returned by the native application. At this time, the web page can successfully display the corresponding search information in the client's display interface.

[0159] Please refer to Figure 10 , Figure 10An exemplary flowchart of a method for communication between a native application and a web page, as described in this application embodiment, is applied to a web page and includes the following steps:

[0160] Step S1000: When it is determined that the target function of the native application needs to be called, send the function call information to the native application;

[0161] Step S1001: Receive the function callback result returned by the native application. The function callback result is determined and returned by the native application under the corresponding operating system standard through the target configuration parameters defined in the corresponding business code. The target configuration parameters defined in the business code under any operating system standard are determined based on the system general communication protocol between the native application and the web page.

[0162] In one alternative implementation, the web page receives the function callback result returned by the native application through a defined generic interface; wherein the generic interface is adapted to the interface callback value obtained from the system's generic communication protocol.

[0163] Please refer to Figure 11 , Figure 11 This application provides an exemplary flowchart of another method for communication between a native application and a web page, applicable to native applications running on any operating system, including the following steps:

[0164] Step S1100: Receive function call information sent by the web page;

[0165] Step S1101: Under the current operating system standard, the function callback result corresponding to the function call information is determined through the target configuration parameters defined in the business code, and the function callback result is returned to the Web page; wherein, the target configuration parameters defined in the business code are determined based on the system general communication protocol between the native application and the Web page.

[0166] In one optional implementation, the target configuration parameters include: the calling method, request parameters, and interface callback values;

[0167] Based on the target configuration parameters defined in the business code, determine the function callback result corresponding to the function call information, and return the function callback result to the web page, including:

[0168] The function callback result is determined by the calling method and request parameters defined in the business code, and then returned to the web page through the interface corresponding to the interface callback value.

[0169] In this application, when the native application communicates with the web page, regardless of the operating system on which the native application runs, the target configuration parameters defined by each business code corresponding to the native application are determined based on the system's general communication protocol. That is, the configuration parameters defined in each business code are consistent, avoiding the situation where the configuration parameters defined in different business codes of the same native application are inconsistent under different operating systems, further reducing the workload of web page adaptation and lowering adaptation costs.

[0170] Example 3: A device for communication between native applications and web pages.

[0171] Based on the same inventive concept as the above-described method embodiments of this application, this application also provides a device applied to a web page, and the principle of the device in solving the problem is similar to that of the above-described method. Therefore, the implementation of the device can refer to the implementation of the above-described method, and repeated details will not be described again.

[0172] Please refer to Figure 12 , Figure 12 This application provides an exemplary embodiment of a device structure diagram for communication between a native application and a web page, applied to a web page. The device 1200 for communication between the native application and the web page includes:

[0173] The sending unit 1201 is used to send function call information to the native application when it is determined that the target function of the native application needs to be called.

[0174] The first receiving unit 1202 is used to receive the function callback result returned by the native application. The function callback result is determined and returned by the native application under the corresponding operating system standard through the target configuration parameters defined in the corresponding business code. The target configuration parameters defined in the business code under any operating system standard are determined based on the system general communication protocol between the native application and the web page.

[0175] In one optional implementation, the first receiving unit 1202 is specifically used for:

[0176] The system receives function callback results returned by the native application through a defined generic interface; the generic interface is adapted to the interface callback value obtained from the system's general communication protocol.

[0177] Based on the same inventive concept as the above-described method embodiments of this application, this application also provides another device for communication between native applications and web pages, which is applied to native applications running under any operating system standard. The principle of this device in solving the problem is similar to the method of the above embodiments. Therefore, the implementation of the device can refer to the implementation of the above method, and the repeated parts will not be described again.

[0178] Please refer to Figure 13 , Figure 13 This application provides an exemplary embodiment of a device structure diagram for communication between a native application and a web page, applicable to a native application running under any operating system standard. The device 1300 for communication between the native application and the web page includes:

[0179] The second receiving unit 1301 is used to receive function call information sent by the Web page;

[0180] Return unit 1302 is used to determine the function callback result corresponding to the function call information through the target configuration parameters defined in the business code under the current operating system standard, and return the function callback result to the Web page; wherein, the target configuration parameters defined in the business code are determined based on the system general communication protocol between the native application and the Web page.

[0181] In one alternative implementation, the business code is determined as follows:

[0182] An abstract syntax tree scan analysis is performed on the system's general communication protocol to generate a syntax tree containing the target configuration parameters;

[0183] By using an iterator, the syntax tree is traversed to generate the corresponding business code for the native application under various operating system standards.

[0184] In one optional implementation, an abstract syntax tree scan analysis is performed on the system's general communication protocol to generate a syntax tree containing the target configuration parameters, including:

[0185] The lexical analyzer, based on the defined lexical rules, converts the system's general communication protocol into a sequence of identifiers, where the identifier sequence contains the target configuration parameters.

[0186] The parser transforms a sequence of identifiers into a syntax tree containing target configuration parameters, based on defined syntax rules.

[0187] In one optional implementation, after performing abstract syntax tree scanning analysis on the system's general communication protocol to generate a syntax tree containing the target configuration parameters, the method further includes:

[0188] The syntax tree is re-edited to obtain a target syntax tree containing the target configuration parameters, wherein the number of levels in the target syntax tree is less than the number of levels in the syntax tree.

[0189] In one alternative implementation, an iterator is used to traverse the syntax tree and generate the corresponding business code for the native application under various operating system standards, including:

[0190] If the native application runs on the first operating system, the syntax tree is traversed through the first iterator supported by the first operating system to generate business code in Java code format;

[0191] If the native application runs on a second operating system, the syntax tree is traversed using the second iterator supported by the second operating system to generate business code in Objective-C format.

[0192] In one optional implementation, after generating the corresponding business code for the native application under various operating system standards based on the syntax tree, the method further includes:

[0193] Each generated business code is submitted to its respective information management database.

[0194] In one optional implementation, the target configuration parameters include: the calling method, request parameters, and interface callback values;

[0195] The return unit 1302 is specifically used to: determine the function callback result through the calling method and request parameters defined in the business code, and return the function callback result to the Web page through the interface corresponding to the interface callback value.

[0196] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. Of course, in implementing this application, the functions of each module (or unit) can be implemented in one or more software or hardware components.

[0197] Having introduced the method and apparatus for native application and web page communication according to exemplary embodiments of this application, the following describes the apparatus for native application and web page communication according to another exemplary embodiment of this application.

[0198] In some possible implementations, the apparatus for native application communication with a web page according to this application may include at least a processor and a memory. The memory stores program code that, when executed by the processor, causes the processor to perform the steps of the methods for native application communication with a web page according to various exemplary embodiments of this application described herein.

[0199] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

[0200] Having described the methods and apparatus for native application and web page communication according to exemplary embodiments of this application, we will now describe an electronic device according to another exemplary embodiment of this application.

[0201] Based on the same inventive concept as the method embodiments described above, this application also provides an electronic device, please refer to... Figure 14 , Figure 14 An exemplary structural diagram of an electronic device is provided in an embodiment of this application. The electronic device includes components such as a communication component 1410, a memory 1420, a display unit 1430, a camera 1440, a sensor 1450, an audio circuit 1460, a Bluetooth module 1470, and a processor 1480.

[0202] The communication component 1410 is used to communicate with the server. In some embodiments, it may include a Circuit-Based Wireless Fidelity (WiFi) module, which is a short-range wireless transmission technology. Electronic devices can use the WiFi module to help users send and receive information.

[0203] The memory 1420 can be used to store software programs and data. The processor 1480 executes various functions of the terminal device 110 and performs data processing by running the software programs or data stored in the memory 1420. The memory 1420 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. The memory 1420 stores the operating system that enables the terminal device 110 to run. In this application, the memory 1420 may store the operating system and various clients, and may also store code for executing the methods of communicating between the native application and the web page in the embodiments of this application.

[0204] The display unit 1430 can also be used for a graphical user interface (GUI) of information input by the user or information provided to the user, as well as various menus of the terminal device 110. Specifically, the display unit 1430 may include a display screen 1432 disposed on the front of the terminal device 110. The display screen 1432 may be configured as a liquid crystal display, a light-emitting diode, or the like. The display unit 1430 can be used for the comment editing interface to be published, etc., in the embodiments of this application.

[0205] The display unit 1430 can also be used to receive input digital or character information and generate signal inputs related to user settings and function control of the terminal device 110. Specifically, the display unit 1430 may include a touch screen 1431 disposed on the front of the terminal device 110, which can collect touch operations of the user on or near it, such as clicking a button, dragging a scroll box, etc.

[0206] The touch screen 1431 can be placed on top of the display screen 1432, or the touch screen 1431 can be integrated with the display screen 1432 to realize the input and output functions of the terminal device 110. After integration, it can be referred to as a touch screen.

[0207] Camera 1440 can be used to capture still images, which users can then post comments on via the application. There can be one or multiple cameras 1440. An object is projected onto a photosensitive element through a lens, generating an optical image. This photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then transmitted to the processor 1480 for conversion into a digital image signal.

[0208] The terminal device may also include at least one sensor 1450, such as an accelerometer 1451, a proximity sensor 1452, a fingerprint sensor 1453, and a temperature sensor 1454. The terminal device may also be equipped with other sensors such as a gyroscope, barometer, hygrometer, thermometer, infrared sensor, light sensor, and motion sensor.

[0209] Audio circuitry 1460, speaker 1461, and microphone 1462 provide an audio interface between the user and terminal device 110. Audio circuitry 1460 converts received audio data into electrical signals, which are then transmitted to speaker 1461, where they are converted into sound signals for output. Terminal device 110 may also be equipped with volume buttons for adjusting the volume of the sound signal. Conversely, microphone 1462 converts collected sound signals into electrical signals, which are then received by audio circuitry 1460, converted back into audio data, and output to communication component 1410 for transmission to, for example, another terminal device 110, or to memory 1420 for further processing.

[0210] The Bluetooth module 1470 is used to interact with other Bluetooth devices that also have a Bluetooth module via the Bluetooth protocol. For example, a terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smartwatch) that also has a Bluetooth module through the Bluetooth module 1470, thereby exchanging data.

[0211] The processor 1480 is the control center of the terminal device, connecting various parts of the terminal through various interfaces and lines. It executes software programs stored in the memory 1420 and calls data stored in the memory 1420 to perform various functions and process data of the terminal device. In some embodiments, the processor 1480 may include one or more processing units; the processor 1480 may also integrate an application processor and a baseband processor, wherein the application processor mainly handles the operating system, user interface, and client, and the baseband processor mainly handles wireless communication. It is understood that the baseband processor may not be integrated into the processor 1480. In this application, the processor 1480 can run the operating system, client, user interface, and touch response, as well as the method for viewing application data in the embodiments of this application. Furthermore, the processor 1480 is coupled to the display unit 1430.

[0212] In some possible implementations, various aspects of the native application and web page methods provided in this application can also be implemented in the form of a program product, which includes a computer program that, when the program product is run on an electronic device, causes the electronic device to perform the steps in the native application and web page methods according to the various exemplary embodiments of this application described above.

[0213] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0214] The program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on a computing device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.

[0215] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.

[0216] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0217] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

[0218] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0219] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing a computer-usable computer program.

[0220] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0221] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for communication between a native application and a web page, characterized in that, Applied to a web page, the method includes: When it is determined that a target function of the native application needs to be invoked, function invocation information is sent to the native application; The native application receives a function callback result, which is determined and returned by the native application under the corresponding operating system standard through the target configuration parameters defined in the corresponding business code. The target configuration parameters defined in the business code under any operating system standard are determined based on the system general communication protocol between the native application and the web page. The business code is determined in the following way: Using a lexical analyzer, based on defined lexical rules, the system's general communication protocol is converted into a sequence of identifiers, wherein the identifier sequence contains the target configuration parameters; The identifier sequence is converted into a syntax tree containing the target configuration parameters by a parser based on the defined syntax rules. By iterating through the syntax tree using an iterator, the corresponding business code for the native application under various operating system standards is generated.

2. The method as described in claim 1, characterized in that, The step of receiving the function callback result returned by the native application includes: The system receives the function callback results returned by the native application through a defined general interface; wherein the general interface is adapted to the interface callback value obtained from the system's general communication protocol.

3. A method for communication between a native application and a web page, characterized in that, Applied to native applications running under any operating system standard, the method includes: Receive function call information sent from the web page; Under the current operating system standard, the function callback result corresponding to the function call information is determined by the target configuration parameters defined in the business code, and the function callback result is returned to the web page; wherein, the target configuration parameters defined in the business code are determined based on the system general communication protocol between the native application and the web page; The business code is determined in the following way: Using a lexical analyzer, based on defined lexical rules, the system's general communication protocol is converted into a sequence of identifiers, wherein the identifier sequence contains the target configuration parameters; The identifier sequence is converted into a syntax tree containing the target configuration parameters by a parser based on the defined syntax rules. By iterating through the syntax tree using an iterator, the corresponding business code for the native application under various operating system standards is generated.

4. The method as described in claim 3, characterized in that, After converting the identifier sequence into a syntax tree containing the target configuration parameters, the process further includes: The syntax tree is re-edited to obtain a target syntax tree containing the target configuration parameters, wherein the number of levels in the target syntax tree is less than the number of levels in the syntax tree, and the target syntax tree is used to generate the business code corresponding to the native application under each operating system standard.

5. The method as described in claim 3, characterized in that, The step of traversing the syntax tree using an iterator to generate the corresponding business code for the native application under various operating system standards includes: If the native application runs under the first operating system, the syntax tree is traversed through the first iterator supported by the first operating system to generate business code in Java code format; If the native application runs on a second operating system, the syntax tree is traversed using a second iterator supported by the second operating system to generate business code in Objective-C format.

6. The method as described in claim 3, characterized in that, After traversing the syntax tree and generating the corresponding business code for the native application under various operating system standards, the process includes: Each generated business code is submitted to its respective information management database.

7. The method as described in claim 3, characterized in that, The target configuration parameters include: the calling method, request parameters, and interface callback values; The step of determining the function callback result corresponding to the function call information through the target configuration parameters defined in the business code, and returning the function callback result to the web page, includes: The function callback result is determined by the calling method and request parameters defined in the business code, and then returned to the web page through the interface corresponding to the interface callback value.

8. A device for communication between a native application and a web page, characterized in that, Applied to a web page, the device includes: The sending unit is used to send function call information to the native application when it is determined that a target function of the native application needs to be called. The first receiving unit is used to receive the function callback result returned by the native application. The function callback result is determined and returned by the native application under the corresponding operating system standard through the target configuration parameters defined in the corresponding business code. The target configuration parameters defined in the business code under any operating system standard are determined based on the system general communication protocol between the native application and the Web page. The business code is determined in the following way: Using a lexical analyzer, based on defined lexical rules, the system's general communication protocol is converted into a sequence of identifiers, wherein the identifier sequence contains the target configuration parameters; The identifier sequence is converted into a syntax tree containing the target configuration parameters by a parser based on the defined syntax rules. By iterating through the syntax tree using an iterator, the corresponding business code for the native application under various operating system standards is generated.

9. A device for communication between a native application and a web page, characterized in that, The device is designed for native applications running under any operating system standard and includes: The second receiving unit is used to receive function call information sent by the web page; The return unit is used to determine the function callback result corresponding to the function call information under the current operating system standard, based on the target configuration parameters defined in the business code, and return the function callback result to the Web page; wherein, the target configuration parameters defined in the business code are determined based on the system general communication protocol between the native application and the Web page; The business code is determined in the following way: Using a lexical analyzer, based on defined lexical rules, the system's general communication protocol is converted into a sequence of identifiers, wherein the identifier sequence contains the target configuration parameters; The identifier sequence is converted into a syntax tree containing the target configuration parameters by a parser based on the defined syntax rules. By iterating through the syntax tree using an iterator, the corresponding business code for the native application under various operating system standards is generated.

10. An electronic device, characterized in that, The electronic device includes: a memory and a processor, wherein: The memory is used to store computer programs; The processor is configured to execute the computer program to implement the steps of the method according to any one of claims 1-2 or 3-7.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method according to any one of claims 1-2 or 3-7.

12. A computer program product, characterized in that, It includes computer instructions that, when executed by a processor, implement the steps of the method described in any one of claims 1-2 or 3-7.