Communication method and device between mobile application and Web page, equipment and medium

By receiving and executing API call instructions sent by mobile applications in a web page, and obtaining and calling the target JS API, the problems of low flexibility and poor reliability of interaction between mobile applications and web pages in the prior art are solved, and structured communication and high reliability communication effects are achieved.

CN119537053APending Publication Date: 2025-02-28PERSAGY TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411604164.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

In the prior art, the interaction mode between mobile applications and web pages is low in flexibility and has great limitations, especially in synchronous interaction scenarios, which leads to logical errors or data inconsistent exceptions, reducing the reliability of communication.

Method used

By receiving the API call instructions sent by the WebView framework of the mobile application in the web page and executing them in sequence in the order of receiving instructions, obtaining the target API name and parameter description information that matches the target API call instructions, obtaining the target JS API inside the web page, and calling and executing the target JS API based on the target parameter description information.

Benefits of technology

Structured communication is realized, providing a new way of communication between mobile applications and web pages, adapting to various different communication scenarios, and improving the reliability and flexibility of communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537053A_ABST
    Figure CN119537053A_ABST
Patent Text Reader

Abstract

The invention discloses a communication method and device between a mobile application and a Web page, equipment and a medium. The method executed by the Web page comprises the following steps: receiving and executing instructions sent by the mobile application according to a receiving sequence; when the target instruction is executed, obtaining a matched target API name and target parameter description information; and obtaining a target JS API matched with the target API name, and executing the target JS API based on the target parameter description information. According to the technical scheme provided by the embodiment of the invention, the JS API calling information is packaged, so that structured communication is realized, and a new mode of communication between the mobile application and the Web page is realized so as to adapt to various different communication scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of mobile application development, and in particular to a method, device, equipment and medium for communication between a mobile application and a Web page. Background Art

[0002] As users' demands for application functions increase, the interaction between the WebView (web page view) of a mobile application and the JS (JavaScript) of a web page (Internet web page) becomes more frequent and complex.

[0003] In the prior art, when a mobile application interacts with a web page, it is mainly triggered by the mobile application to call the API (Application Programming Interface) in the web page, and the web page autonomously completes the call execution of the internal API. In fact, the above-mentioned interaction method implemented by directly calling the API has low flexibility and great limitations. In particular, this interaction method can only realize asynchronous communication. Due to the limitation of asynchronous communication, in the synchronous interaction scenario, the web page returns control to the mobile application before the execution of the API (Application Programming Interface) call instruction is completed, causing the mobile application to perform other operations while waiting for the execution result of the web page, resulting in the state of the mobile application has changed before the execution of the web page is completed, resulting in logical errors or data inconsistency exceptions, and reducing the reliability of communication between the mobile application and the web page. Summary of the invention

[0004] The present invention provides a method, device, equipment and medium for communication between a mobile application and a Web page, so as to provide a new way for communication between a mobile application and a Web page, so as to adapt to various communication scenarios.

[0005] According to one aspect of an embodiment of the present invention, a method for communication between a mobile application and a web page is provided, which is executed by the web page and includes:

[0006] Receive at least one API call instruction sent by the WebView framework of the mobile application, and execute each API call instruction in sequence according to the order in which the instructions are received;

[0007] The API call instruction is in JSON format and includes the API name and parameter description information;

[0008] When executing the target API call instruction, obtain the target API name and target parameter description information that match the target API call instruction;

[0009] The target JS API matching the target API name is obtained within the web page, and the target JS API is called and executed based on the target parameter description information.

[0010] According to another aspect of an embodiment of the present invention, a method for communication between a mobile application and a web page is provided, which is executed by the mobile application and includes:

[0011] Load web pages through the WebView framework;

[0012] Send at least one API call instruction to the web page through the WebView framework;

[0013] Among them, the API call instruction is in JSON format, and the API call instruction includes the API name, parameter description information and blocking description information used to identify whether to block the execution of subsequent API call instructions; the web page is used to execute each API call instruction in sequence, and execute each API call instruction in a synchronous or asynchronous call manner according to the blocking description information defined in the API call instruction.

[0014] According to another aspect of an embodiment of the present invention, there is also provided a communication device between a mobile application and a web page, which is configured in the web page and includes:

[0015] An API call instruction execution module, used to receive at least one API call instruction sent by the WebView framework of the mobile application, and execute each API call instruction in sequence according to the order in which the instructions are received;

[0016] The API call instruction is in JSON format and includes the API name and parameter description information;

[0017] A matching information acquisition module is used to obtain the target API name and target parameter description information that match the target API call instruction when executing the target API call instruction;

[0018] The target JS API execution module is used to obtain the target JS API matching the target API name inside the Web page, and call and execute the target JS API based on the target parameter description information.

[0019] According to another aspect of an embodiment of the present invention, there is also provided a communication device between a mobile application and a web page, which is configured in the mobile application and includes:

[0020] Web page loading module, used to load web pages through the WebView framework;

[0021] An API call instruction sending module, used to send at least one API call instruction to a Web page through a WebView framework;

[0022] Among them, the API call instruction is in JSON format, and the API call instruction includes the API name, parameter description information and blocking description information used to identify whether to block the execution of subsequent API call instructions; the web page is used to execute each API call instruction in sequence, and execute each API call instruction in a synchronous or asynchronous call manner according to the blocking description information defined in the API call instruction.

[0023] According to another aspect of an embodiment of the present invention, an electronic device is provided, the electronic device comprising:

[0024] at least one processor; and

[0025] a memory communicatively connected to the at least one processor; wherein,

[0026] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the communication method between the mobile application and the web page executed by the web page described in any embodiment of the present invention, or the communication method between the mobile application and the web page executed by the mobile application.

[0027] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the communication method between a mobile application executed by a web page and a web page described in any embodiment of the present invention, or the communication method between a mobile application executed by a mobile application and a web page.

[0028] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the method described in any embodiment of the present invention are implemented.

[0029] The technical solution of the embodiment of the present invention receives at least one application program interface API call instruction sent by the WebView framework of the mobile application, and executes each API call instruction in sequence according to the order in which the instructions are received; when executing the target API call instruction, obtains the target API name and target parameter description information that match the target API call instruction; obtains the target JS API that matches the target API name inside the Web page, and calls and executes the target JS API based on the target parameter description information. The technical solution of the embodiment of the present invention realizes structured communication by encapsulating JS API call information, and realizes a new way of communication between mobile applications and Web pages to adapt to various communication scenarios. It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easy to understand through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0031] Figure 1 is a flow chart of a method for communication between a mobile application and a web page provided according to a first embodiment of the present invention;

[0032] Figure 2 is a flow chart of another method for communication between a mobile application and a Web page provided according to Embodiment 2 of the present invention;

[0033] Figure 3 It is a schematic diagram of an instruction structure applicable to an embodiment of the present invention;

[0034] Figure 4 This is an example diagram of an API call instruction applicable to an embodiment of the present invention;

[0035] Figure 5 is a schematic diagram of the structure of a communication device between a mobile application and a web page provided according to a third embodiment of the present invention;

[0036] Figure 6 is a schematic diagram of the structure of another communication device between a mobile application and a Web page provided according to a fourth embodiment of the present invention;

[0037] Figure 7 It is a structural schematic diagram of an electronic device that implements the communication method between a mobile application and a Web page according to an embodiment of the present invention. DETAILED DESCRIPTION

[0038] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0039] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0040] Embodiment 1

[0041] Figure 1 This is a flow chart of a communication method between a mobile application and a web page provided in the first embodiment of the present invention. This embodiment is applicable to the case where a web page receives and sequentially executes an API call instruction sent by the WebView framework of the mobile application. The method can be executed by a communication device between the mobile application and the web page. The communication device between the mobile application and the web page can be implemented in the form of hardware and / or software and can generally be configured in an electronic device. Figure 1 As shown, the method includes:

[0042] S110, receiving at least one API calling instruction sent by the WebView framework of the mobile application, and executing each API calling instruction in sequence according to the order in which the instructions are received.

[0043] The API call instruction is in JSON format and includes the API name and parameter description information.

[0044] In the embodiment of the present invention, JSON is a data exchange format that uses key-value pairs to store data, is lightweight, supports multiple languages, and is easy to parse and generate. It is a data format commonly used for network requests and responses in mobile application development. API call instructions refer to instructions for interacting with external services or systems through specific interfaces in an application. The calling object of an API call instruction can be local (such as calling a hardware function of a device) or remote (such as calling a network service).

[0045] The API call instruction is encapsulated in JSON format, and the API call instruction may include the API name and parameter description information. The parameter description information can be specifically understood as: the parameter list of the API, which may include parameter content, parameter name and parameter type (string, number, object or function), etc. The WebView framework is a component that provides a series of APIs to load and display web pages, and can interact with JS (a programming language used to implement interactive functions in web pages or applications) code in the web page.

[0046] S120. When executing the target API calling instruction, obtain the target API name and target parameter description information that match the target API calling instruction.

[0047] In an embodiment of the present invention, the target API call instruction can be specifically understood as: the API call instruction currently executed by the web page. The target API name can be specifically understood as: the API name recorded by the target API call instruction. The target parameter description information can be specifically understood as: the parameter description information recorded by the target API call instruction. Specifically, the web page receives at least one API call instruction sent by the WebView framework of the mobile application and executes each API call instruction in sequence according to the order in which the instructions are received. When executing the target API call instruction, since the target API call instruction is in the JSON format that uses key-value pairs to store data, the target API name and target parameter description information that match the target API call instruction can be obtained through the key value. For example, when the target API call instruction is in the following form:

[0048] {"ApiName":"loadScene",

[0049] "ParamArray":{

[0050] "Param":"Zhang San",

[0051] "ParamName":"Name",

[0052] "Type":"string"}

[0053] Correspondingly, the target API name that matches the target API call instruction is loadScene; the target parameter description information includes that the target parameter content is Zhang San, the target parameter name is name, and the target parameter type is string.

[0054] S130: Acquire a target JS API matching the target API name within the Web page, and call and execute the target JS API based on the target parameter description information.

[0055] In the embodiment of the present invention, the target JS API can be specifically understood as: a JavaScript API interface that matches the name of the target API currently to be executed.

[0056] Specifically, determine the name of the API to be called, obtain the target JS API that matches the target API name within the web page, and prepare the parameters required by the API based on the target parameter description information. Each parameter must meet the requirements of the API, such as the correct data type and format, and call and execute the target JS API.

[0057] The technical solution of the embodiment of the present invention receives at least one application program interface API call instruction sent by the WebView framework of the mobile application, and executes each API call instruction in sequence according to the order in which the instructions are received; when executing the target API call instruction, obtains the target API name and target parameter description information that match the target API call instruction; obtains the target JS API that matches the target API name inside the Web page, and calls and executes the target JS API based on the target parameter description information. By encapsulating the JS API call information, structured communication is achieved, providing a new way of communication between mobile applications and Web pages to adapt to various communication scenarios.

[0058] On the basis of the above embodiments, the API call instruction may further include: blocking description information for identifying whether to block the execution of subsequent API call instructions;

[0059] Accordingly, when executing the target API call instruction, while obtaining the target API name and target parameter description information matching the target API call instruction, it may also include:

[0060] Get the target blocking description information that matches the target API call instruction;

[0061] Accordingly, after calling and executing the target JS API based on the target parameter description information, the following may also be included:

[0062] If the target blocking description information is blocking, after the target JS API is executed, continue to execute the next API call instruction; otherwise, directly execute the next API call instruction.

[0063] The blocking description information can be specifically understood as: an identifier used to identify whether to block the execution of subsequent API call instructions, which defaults to true, that is, the mobile application will wait for the web page to complete the execution of the API call instruction before continuing to execute the next API call instruction, ensuring the order of operations and the accuracy of the results. The target blocking description information can be specifically understood as: the blocking description information recorded by the target API call instruction.

[0064] Specifically, the target blocking description information matching the target API call instruction is detected. If it is true, it indicates blocking. After the target JS API is executed, the next API call instruction is continued to be executed to achieve synchronous execution between the mobile application and the Web page. If it is false, it indicates non-blocking. There is no need to wait for the target JS API to be executed. The next API call instruction can be executed directly to achieve asynchronous execution between the mobile application and the Web page.

[0065] Furthermore, when the target API call instruction is in the following form:

[0066] {"ApiName":"loadScene",

[0067] "ParamArray":{

[0068] "Param":"Zhang San",

[0069] "ParamName":"Name",

[0070] "Type":"string"},

[0071] "IsAwait":true}

[0072] In addition to the information described above, the target API call instruction also includes target blocking description information IsAwait is true, ie blocking.

[0073] The technical solution of the embodiment of the present invention, when it is determined that the target blocking description information is blocked, continues to execute the next API call instruction after the target JS API is executed; otherwise, directly executes the next API call instruction, and manages the synchronous scenario and asynchronous scenario of the API call by controlling the execution order of the instructions and the blocking description information field, thereby improving the reliability of communication between the mobile application and the web page in different scenarios.

[0074] Further, in an embodiment of the present invention, the API call instruction may also include: a delay time before the API is executed;

[0075] Accordingly, when executing the target API call instruction, while obtaining the target API name and target parameter description information matching the target API call instruction, it may also include:

[0076] Get the target delay time that matches the target API call instruction;

[0077] Accordingly, the target JS API is called and executed based on the target parameter description information, including:

[0078] After waiting for the target delay time, the target JS API is called and executed based on the target parameter description information.

[0079] In the embodiment of the present invention, the target delay time can be specifically understood as: the delay time recorded by the target API call instruction, which is used to indicate a specific waiting time set before executing the target API call instruction.

[0080] This optional implementation can reduce the server load through appropriate delays, avoiding throttling or blocking due to too fast requests; when multiple API call instructions need to be executed in a specific order, the delay can ensure that the API call instructions are executed in the correct order; when processing large amounts of data or executing long-running API call instructions, the delay can provide users with buffer time, thereby improving the reliability of communication between mobile applications and web pages.

[0081] Furthermore, in the embodiment of the present invention, the API call instruction may further include: return value receiving description information for identifying whether to receive the return value, and a return value callback function;

[0082] Accordingly, when executing the target API call instruction, while obtaining the target API name and target parameter description information matching the target API call instruction, it may also include:

[0083] Obtain target return value receiving description information that matches the target API call instruction, and when the target return value receiving description information is a receiving return value, obtain a target return value callback function that matches the target API call instruction;

[0084] Correspondingly, calling and executing the target JS API based on the target parameter description information may also include:

[0085] If the target return value receiving description information is receiving the return value, after obtaining the target return value fed back by the target JS API, the target return value callback function is called to notify the mobile application of the target return value so that the mobile application can generate an execution log that matches the target API call instruction.

[0086] In the embodiment of the present invention, the target return value receiving description information can be specifically understood as: the return value receiving description information recorded by the target API call instruction. The return value receiving description information is an identifier indicating whether the mobile application receives the return value. The default value is false, indicating that the return value is not received. If true, the mobile application will be notified of the return value of the API after the target API call instruction is executed on the web page. The target return value callback function can be specifically understood as: the return value callback function recorded by the target API call instruction. The return value callback function is a function that takes a function as a parameter, is called after the target API call instruction is completed, and is used to return the result.

[0087] In this optional implementation, by setting the return value and the return value callback function, the problem of not being able to receive the return parameters of JS asynchronous execution due to the asynchronous communication restrictions between the mobile application and the web page is solved, and logging is performed by recording the return value, so that the user's interaction behavior can be reproduced, and the problems encountered by the user can be tracked and diagnosed, and the context environment when the problem occurs can be understood, which helps optimize application performance, thereby improving the reliability of communication between the mobile application and the web page.

[0088] Further, in an embodiment of the present invention, the API call instruction may also include: mode description information for identifying whether to enter the debug mode, instruction deletion description information for identifying whether to execute its own API call instruction in the debug mode, and blocking description information for identifying whether to block the execution of subsequent API call instructions in the debug mode;

[0089] Accordingly, when executing the target API call instruction, while obtaining the target API name and target parameter description information matching the target API call instruction, it may also include:

[0090] Obtain target mode description information, target instruction deletion description information, and target blocking description information that match the target API call instruction;

[0091] The method may further comprise:

[0092] If the target mode description information is the debug mode, then when the target instruction deletion description information is not to delete, the target JSAPI matching the target API name is called and executed based on the target parameter description information in the pre-built debug mode;

[0093] After the target JS API is executed, if the target blocking description information is blocking, the next API call instruction is terminated; otherwise, the next API call instruction continues to be executed.

[0094] In the embodiment of the present invention, the target mode description information can be specifically understood as: the mode description information recorded by the target API call instruction, the mode description information is an identifier used to identify whether to enter the debug mode, and the debug mode is a process used to find and repair errors in software in computer programming. The target instruction deletion description information can be specifically understood as: the deletion description information recorded by the target API call instruction, the deletion description information is an identifier used to identify whether to execute its own API call instruction in the debug mode, that is, whether to delete the instruction in the debug mode, or whether to not execute the instruction at all. The target blocking description information can be specifically understood as: the blocking description information recorded by the target API call instruction, the blocking description information is an identifier used to identify whether to block the execution of subsequent API call instructions in the debug mode.

[0095] In this embodiment, the mode description information, instruction deletion description information and blocking description information fields are used to control whether to enter the debugging mode, whether to execute the target API call instruction in the debugging mode and whether to block the subsequent API call instruction execution in the debugging mode. Developers can enter the debugging mode to capture abnormal situations, provide fast debugging and problem location means, reduce development and maintenance costs, and improve the reliability of communication between mobile applications and Web pages.

[0096] Embodiment 2

[0097] Figure 2 This is a flowchart of another method for communicating between a mobile application and a web page provided in the second embodiment of the present invention. This embodiment is applicable to the case where a mobile application sends an API call instruction to a web page. The method can be executed by a communication device between a mobile application and a web page. The communication device between a mobile application and a web page can be implemented in the form of hardware and / or software and can generally be configured in an electronic device. Figure 2 As shown, the method includes:

[0098] S210: Loading a Web page through the WebView framework.

[0099] S220: Send at least one API call instruction to the Web page through the WebView framework.

[0100] Among them, the API call instruction is in JSON format, and the API call instruction includes the API name, parameter description information and blocking description information used to identify whether to block the execution of subsequent API call instructions; the web page is used to execute each API call instruction in sequence, and execute each API call instruction in a synchronous or asynchronous call manner according to the blocking description information defined in the API call instruction.

[0101] The technical solution of the embodiment of the present invention is to load a Web page through the WebView framework; send at least one API call instruction to the Web page through the WebView framework; wherein the API call instruction is in JSON format, and includes an API name, parameter description information, and blocking description information for identifying whether to block the execution of subsequent API call instructions; the Web page is used to execute each API call instruction in sequence, and execute each API call instruction in a synchronous or asynchronous call manner according to the blocking description information defined in the API call instruction. The mobile application implements structured communication by sending encapsulated JS API call instructions to the Web page, and manages synchronous and asynchronous scenarios of API calls by controlling the execution order of the Web page instructions and the blocking description information field of the JS API call instruction, thereby improving the reliability of communication between the mobile application and the Web page in different scenarios.

[0102] Further, in an embodiment of the present invention, the API call instruction may also include: at least one of the following: a delay time before API execution, a return value receiving description information for identifying whether to receive a return value, a return value callback function, a mode description information for identifying whether to enter a debug mode, an instruction deletion description information for identifying whether to execute its own API call instruction in the debug mode, and a blocking description information for identifying whether to block the execution of subsequent API call instructions in the debug mode;

[0103] The method may further comprise:

[0104] Whenever a target return value fed back by a Web page for at least one target API call instruction is received, an execution log matching each target API call instruction is generated according to the target return value.

[0105] Specifically, the API call instruction may also include at least one of the following: a delay time before API execution, a return value receiving description information for identifying whether to receive a return value, a return value callback function, a mode description information for identifying whether to enter a debugging mode, an instruction deletion description information for identifying whether to execute its own API call instruction in the debugging mode, and a blocking description information for identifying whether to block the execution of subsequent API call instructions in the debugging mode. Accordingly, when the return value receiving description information in the API call instruction is receiving a return value, after the execution of the target API call instruction is completed, the Web page will send the target return value to the mobile application. Whenever the mobile application receives the target return value fed back by the Web page for at least one target API call instruction, it generates an execution log matching each target API call instruction according to the target return value, thereby solving the problem of being unable to receive the return parameter of JS asynchronous execution due to the asynchronous communication limitation between the mobile application and the Web page, and logging by recording the return value can reproduce the user's interactive behavior, track and diagnose the problems encountered by the user, understand the context when the problem occurs, help optimize the application performance, and thus improve the reliability of communication between the mobile application and the Web page.

[0106] Specific application scenarios

[0107] In the development, operation and maintenance of mobile applications, especially hybrid applications that combine native applications and Web applications, the communication between the WebView framework of the mobile application and the JS of the Web page usually has the problem of being unable to receive the return parameters of JS asynchronous execution; the way in which the WebView framework of the mobile application calls the JS of the Web page is asynchronous and cannot be executed synchronously, thus causing various abnormal problems in the complex interaction process; due to the limitation of asynchronous communication, the mobile application cannot accurately obtain the return value after each Web page executes the call instruction; the JS of the mobile application and the Web page belong to independent systems respectively. In high-density communication scenarios, due to frequent communication, it will cause difficult-to-reproduce problems when completing the interaction. The root cause of the problem is difficult to accurately locate, and it is difficult to debug and reproduce the problem, which increases the cost of development and maintenance. In order to solve the above problems, an embodiment of the present invention proposes a communication method between a mobile application and a Web page. First, a specific JSON structure is used to encapsulate the call information of each API describing the JS framework. Figure 3 is a schematic diagram of an instruction structure applicable to an embodiment of the present invention, such as Figure 3 As shown, an instruction represents the execution of an API call instruction. The structure includes the following fields:

[0108] ApiName: The name of the API to be called. This is a required field.

[0109] AwaitTime: The delay time before the API is executed. This is an optional field.

[0110] ParamArray: API parameter list, including parameter content, parameter name, parameter type, etc. For details, please refer to the API documentation. If there is no parameter, it can be empty. Optional fields.

[0111] Param: The parameter content corresponding to the API. If ParamArray is not empty, it is a required field.

[0112] ParamName: The parameter name corresponding to the API is only for instruction readability and no logical processing is performed. This field is optional.

[0113] Type: For the type of the parameter corresponding to the API, refer to the API documentation. It can be string, number, object, or function, etc. This is a required field.

[0114] IsNeedReturn: Whether to receive a return value. The default value is false. If true, the return value of the API will be notified to the client. This field is optional.

[0115] GetReturnValueBlockName: Customize the callback function of the return value. The default value is nul1. It will be triggered and returned only when IsNeedReturn is equal to true and the callback function that receives the return value is customized. Optional field.

[0116] Type: instruction execution type. The program defaults to callJsAPI, which means calling Js API. This field is optional.

[0117] callBackSign: API custom identifier, empty by default, used to call the same API cyclically. callBackSign can be used to distinguish different callbacks. This field is optional.

[0118] IsAwait: Whether to block the execution of subsequent instructions. The default value is true, that is, if the current API is an asynchronously executed API, such as a network request, it will be forced to block and wait for the execution to complete before continuing to execute subsequent instructions. This is an optional field.

[0119] Debugger_IsDelete: Whether to delete the instruction, that is, not execute it at all. The default value is false, that is, the API call instruction is executed during debugging.

[0120] Debugger_IsEnd: Whether to block the execution of subsequent APIs. The default value is false, which means that during debugging, the execution of subsequent API call instructions is not blocked.

[0121] Debugger_IsDebugger: Whether to enter debug mode. The default value is false, which means not to enter debug mode.

[0122] SceneName: The scene name executed by the API. It is applicable to applications with multiple scenes. If there is only one scene, the default scene name of the program is PersagyWeb3D. This field is optional.

[0123] The method may specifically include:

[0124] 1. The WebView framework of the mobile application (such as Android) sends an API call instruction in a JSON structure to the web page. The JSON contains information such as the API name, parameters, and callback function.

[0125] Figure 4 is an example diagram of an API call instruction applicable to an embodiment of the present invention, such as Figure 4 As shown, the JS API call instruction includes the corresponding API name, parameter content and parameter type.

[0126] 2. If IsAwait is true, the mobile application will wait for the JS API to complete execution before sending the next instruction, ensuring the synchronization of complex interactions and achieving synchronous communication between the mobile application and the web page.

[0127] 3. If IsNeedReturn is true, after the web page executes the API, it returns the execution result to the mobile application through the callback function. The mobile application records the execution log of the instruction. Through the instruction log, the user's interaction process can be reproduced when the problem occurs, and the problem can be quickly located and repaired. This can solve the debugging and maintenance problems caused by asynchronous execution and frequent communication between existing mobile applications and web pages.

[0128] 4. If Debugger_IsDebugger is true, the debug mode is entered. If Debugger_IsDelete is true, the API call instruction is not executed in the debug mode. If Debugger_IsDelete is false, the API call instruction is executed in the debug mode. If Debugger_IsEnd is true, the execution of the next API call instruction is terminated in the debug mode. If Debugger_IsEnd is false, the execution of the next API call instruction continues in the debug mode.

[0129] The communication method between the mobile application and the web page proposed in the embodiment of the present invention encapsulates the API call information through a specific JSON structure, so that the communication is more structured and more readable, and can effectively manage the high-frequency communication between the WebView framework of the mobile application and the JavaScript of the web page, solve the complexity and abnormality problems caused by traditional asynchronous calls, and facilitate debugging and maintenance by developers. The IsAwait field is defined through the JSON structure to determine whether to block the execution of subsequent instructions, thereby realizing the synchronous and asynchronous management of API calls and avoiding interaction anomalies caused by asynchronous calls. In addition, the mobile application can send API call instructions in batches to control the execution order of the instructions, ensure that the instructions can be executed in the expected order in complex interaction scenarios, and reduce the anomalies caused by asynchronous calls. By returning values ​​and debugging functions and sending instructions in batches, monitoring API call instructions can be realized, and problem scenarios can be efficiently reproduced, and abnormal vulnerabilities can be quickly located and repaired. Through custom identification functions such as callBackSign, different API calls can be accurately marked, the problem of problem location under high-frequency calls is solved, and the reliability of communication between mobile applications and web pages in different scenarios is improved.

[0130] Embodiment 3

[0131] Figure 5 This is a schematic diagram of a communication device between a mobile application and a web page provided in Embodiment 3 of the present invention. Figure 5 As shown, the device includes: an API call instruction execution module 510, a matching information acquisition module 520 and a target JSAPI execution module 530.

[0132] The API call instruction execution module 510 is used to receive at least one API call instruction sent by the WebView framework of the mobile application, and execute each API call instruction in sequence according to the order in which the instructions are received;

[0133] The API call instruction is in JSON format and includes the API name and parameter description information;

[0134] The matching information acquisition module 520 is used to acquire the target API name, target parameter description information and target blocking description information that match the target API call instruction when executing the target API call instruction;

[0135] The target JS API execution module 530 is used to obtain the target JS API matching the target API name inside the Web page, and call and execute the target JS API based on the target parameter description information.

[0136] The technical solution of the embodiment of the present invention receives at least one application program interface API call instruction sent by the WebView framework of the mobile application, and executes each API call instruction in sequence according to the order in which the instructions are received; when executing the target API call instruction, obtains the target API name and target parameter description information that match the target API call instruction; obtains the target JS API that matches the target API name inside the Web page, and calls and executes the target JS API based on the target parameter description information. The technical solution of the embodiment of the present invention realizes structured communication by encapsulating JS API call information, and realizes a new way of communication between mobile applications and Web pages to adapt to various communication scenarios.

[0137] On the basis of the above embodiments, the API call instruction further includes: blocking description information for identifying whether to block the execution of subsequent API call instructions;

[0138] The matching information acquisition module 520 is further used to: when executing the target API call instruction, obtain the target API name and target parameter description information that match the target API call instruction, and obtain the target blocking description information that matches the target API call instruction;

[0139] Accordingly, the following API call instruction execution module may also be included, which is used to:

[0140] After calling and executing the target JS API based on the target parameter description information, if the target blocking description information is blocking, after the target JS API is executed, continue to execute the next API call instruction; otherwise, directly execute the next API call instruction.

[0141] Further, based on the above embodiments, the API call instruction executed by the matching information acquisition module 520 may further include: a delay time before the API is executed.

[0142] Accordingly, based on the above embodiments, the matching information acquisition module 520 can be specifically used for:

[0143] Get the target delay time that matches the target API call instruction.

[0144] Accordingly, based on the above embodiments, the target JS API execution module 530 can be specifically used for:

[0145] After waiting for the target delay time, the target JS API is called and executed based on the target parameter description information.

[0146] Further, based on the above embodiments, the API call instruction executed by the matching information acquisition module 520 may further include: return value receiving description information for identifying whether to receive a return value, and a return value callback function.

[0147] Accordingly, based on the above embodiments, the matching information acquisition module 520 can also be specifically used for:

[0148] The target return value receiving description information that matches the target API call instruction is obtained, and when the target return value receiving description information is a receiving return value, the target return value callback function that matches the target API call instruction is obtained.

[0149] Accordingly, based on the above embodiments, the target JS API execution module 530 can also be specifically used for:

[0150] If the target return value receiving description information is receiving the return value, after obtaining the target return value fed back by the target JS API, the target return value callback function is called to notify the mobile application of the target return value so that the mobile application can generate an execution log that matches the target API call instruction.

[0151] Further, based on the above embodiments, the API call instruction executed by the matching information acquisition module 520 may also include: mode description information for identifying whether to enter the debugging mode, instruction deletion description information for identifying whether to execute its own API call instruction in the debugging mode, and blocking description information for identifying whether to block the execution of subsequent API call instructions in the debugging mode.

[0152] Accordingly, based on the above embodiments, the matching information acquisition module 520 can also be specifically used for:

[0153] Get the target pattern description information, target instruction deletion description information, and target blocking description information that match the target API call instruction.

[0154] Further, based on the above embodiments, the communication device between the mobile application and the Web page provided in the embodiment of the present invention may further include: a target JS API execution module and a target blocking description information detection module.

[0155] A target JS API execution module is used for calling and executing a target JS API matching the target API name based on the target parameter description information in a pre-built debug mode if the target mode description information is a debug mode and the target instruction deletion description information is not to delete;

[0156] The target blocking description information detection module is used to terminate the subsequent API call instruction if the target blocking description information is blocking after the target JS API is executed; otherwise, continue to execute the subsequent API call instruction.

[0157] The communication device between a mobile application and a Web page provided in an embodiment of the present invention can execute the communication method between a mobile application and a Web page executed by a Web page provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.

[0158] Embodiment 4

[0159] Figure 6 This is a schematic diagram of the structure of another communication device between a mobile application and a web page provided in Embodiment 4 of the present invention. Figure 6 As shown, the device includes: a Web page loading module 610 and an API call instruction sending module 620.

[0160] A web page loading module 610, used to load a web page through a WebView framework;

[0161] The API call instruction sending module 620 is used to send at least one API call instruction to the Web page through the WebView framework;

[0162] Among them, the API call instruction is in JSON format, and the API call instruction includes the API name, parameter description information and blocking description information used to identify whether to block the execution of subsequent API call instructions; the web page is used to execute each API call instruction in sequence, and execute each API call instruction in a synchronous or asynchronous call manner according to the blocking description information defined in the API call instruction.

[0163] The technical solution of the embodiment of the present invention is to load a Web page through the WebView framework; send at least one API call instruction to the Web page through the WebView framework; wherein the API call instruction is in JSON format, and includes an API name, parameter description information, and blocking description information for identifying whether to block the execution of subsequent API call instructions; the Web page is used to execute each API call instruction in sequence, and execute each API call instruction in a synchronous or asynchronous call manner according to the blocking description information defined in the API call instruction. The mobile application implements structured communication by sending encapsulated JS API call instructions to the Web page, and manages synchronous and asynchronous scenarios of API calls by controlling the execution order of the Web page instructions and the blocking description information field of the JS API call instruction, thereby improving the reliability of communication between the mobile application and the Web page in different scenarios.

[0164] Further, based on the above embodiments, at least one API call instruction sent by the API call instruction sending module 620 to the Web page may also include: a delay time before API execution, a return value receiving description information for identifying whether to receive a return value, a return value callback function, a mode description information for identifying whether to enter a debugging mode, an instruction deletion description information for identifying whether to execute its own API call instruction in the debugging mode, and a blocking description information for identifying whether to block the execution of subsequent API call instructions in the debugging mode.

[0165] Further, based on the above embodiments, the communication device between the mobile application and the Web page provided in the embodiment of the present invention may further include: an execution log generation module.

[0166] The execution log generation module is used to generate an execution log matching each target API call instruction according to the target return value whenever receiving a target return value fed back by a Web page for at least one target API call instruction.

[0167] The communication device between a mobile application and a Web page provided in an embodiment of the present invention can execute the communication method between a mobile application and a Web page executed by a mobile application provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.

[0168] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0169] Embodiment 5

[0170] Figure 7 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0171] like Figure 7As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0172] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0173] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the communication method between the mobile application and the web page executed by the web page, that is:

[0174] Receive at least one application program interface API call instruction sent by the WebView framework of the mobile application, and execute each API call instruction in sequence according to the order in which the instructions are received;

[0175] The API call instruction is in JSON format and includes the API name and parameter description information;

[0176] When executing the target API call instruction, obtain the target API name and target parameter description information that match the target API call instruction;

[0177] The target JS API matching the target API name is obtained within the web page, and the target JS API is called and executed based on the target parameter description information.

[0178] Or, for example, a communication method between a mobile application and a web page executed by a mobile application, that is:

[0179] Load web pages through the WebView framework;

[0180] Send at least one API call instruction to the web page through the WebView framework;

[0181] Among them, the API call instruction is in JSON format, and the API call instruction includes the API name, parameter description information and blocking description information used to identify whether to block the execution of subsequent API call instructions; the web page is used to execute each API call instruction in sequence, and execute each API call instruction in a synchronous or asynchronous call manner according to the blocking description information defined in the API call instruction.

[0182] In some embodiments, the communication method between the mobile application and the web page executed by the web page, or the communication method between the mobile application and the web page executed by the mobile application can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the communication method between the mobile application and the web page executed by the web page, or the communication method between the mobile application and the web page executed by the mobile application described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the communication method between the mobile application and the web page executed by the web page, or the communication method between the mobile application and the web page executed by the mobile application, by any other appropriate means (for example, by means of firmware).

[0183] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0184] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0185] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0186] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0187] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0188] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0189] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0190] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for communication between a mobile application and a web page, executed by the web page, characterized in that: include: Receive at least one application program interface API call instruction sent by the WebView framework of the mobile application, and execute each API call instruction in sequence according to the order in which the instructions are received; The API call instruction is in JSON format and includes the API name and parameter description information; When executing the target API call instruction, obtain the target API name and target parameter description information that match the target API call instruction; The target JS API matching the target API name is obtained within the web page, and the target JS API is called and executed based on the target parameter description information.

2. The method according to claim 1, characterized in that The API call instruction also includes: blocking description information for identifying whether to block the execution of subsequent API call instructions; Accordingly, when executing the target API call instruction, the target API name and target parameter description information matching the target API call instruction are obtained, and also includes: Get the target blocking description information that matches the target API call instruction; Accordingly, after calling and executing the target JS API based on the target parameter description information, it also includes: If the target blocking description information is blocking, after the target JS API is executed, continue to execute the next API call instruction; otherwise, directly execute the next API call instruction.

3. The method according to claim 2, characterized in that The API call instruction also includes: the delay time before the API is executed; Accordingly, when executing the target API call instruction, the target API name and target parameter description information matching the target API call instruction are obtained, and also includes: Get the target delay time that matches the target API call instruction; Accordingly, the target JS API is called and executed based on the target parameter description information, including: After waiting for the target delay time, the target JS API is called and executed based on the target parameter description information.

4. The method according to claim 1, characterized in that The API call instruction also includes: return value receiving description information for identifying whether to receive the return value, and a return value callback function; Accordingly, when executing the target API call instruction, the target API name and target parameter description information matching the target API call instruction are obtained, and also includes: Obtain target return value receiving description information that matches the target API call instruction, and when the target return value receiving description information is a receiving return value, obtain a target return value callback function that matches the target API call instruction; Accordingly, the target JS API is called and executed based on the target parameter description information, including: If the target return value receiving description information is receiving the return value, after obtaining the target return value fed back by the target JS API, the target return value callback function is called to notify the mobile application of the target return value so that the mobile application can generate an execution log that matches the target API call instruction.

5. The method according to claim 1, characterized in that The API call instruction also includes: mode description information for identifying whether to enter the debug mode, instruction deletion description information for identifying whether to execute its own API call instruction in the debug mode, and blocking description information for identifying whether to block the execution of subsequent API call instructions in the debug mode; Accordingly, when executing the target API call instruction, the target API name and target parameter description information matching the target API call instruction are obtained, and also includes: Obtain target mode description information, target instruction deletion description information, and target blocking description information that match the target API call instruction; The method further comprises: If the target mode description information is debug mode, then when the target instruction deletion description information is not to delete, the target JS API matching the target API name is called and executed based on the target parameter description information in the pre-built debug mode; After the target JS API is executed, if the target blocking description information is blocking, the next API call instruction is terminated; otherwise, the next API call instruction continues to be executed.

6. A method for communication between a mobile application and a web page, executed by the mobile application, characterized in that: include: Load web pages through the WebView framework; Send at least one API call instruction to the web page through the WebView framework; Among them, the API call instruction is in JSON format, and the API call instruction includes the API name, parameter description information and blocking description information used to identify whether to block the execution of subsequent API call instructions; the web page is used to execute each API call instruction in sequence, and execute each API call instruction in a synchronous or asynchronous call manner according to the blocking description information defined in the API call instruction.

7. The method according to claim 6, characterized in that The API call instruction also includes: at least one of: a delay time before API execution, return value receiving description information for identifying whether to receive a return value, a return value callback function, mode description information for identifying whether to enter a debug mode, instruction deletion description information for identifying whether to execute its own API call instruction in the debug mode, and blocking description information for identifying whether to block subsequent API call instructions from being executed in the debug mode; The method further comprises: Whenever a target return value fed back by a Web page for at least one target API call instruction is received, an execution log matching each target API call instruction is generated according to the target return value.

8. A communication device between a mobile application and a web page, configured in the web page, characterized in that: include: An API call instruction execution module, used to receive at least one API call instruction sent by the WebView framework of the mobile application, and execute each API call instruction in sequence according to the order in which the instructions are received; The API call instruction is in JSON format and includes the API name and parameter description information; A matching information acquisition module is used to obtain the target API name and target parameter description information that match the target API call instruction when executing the target API call instruction; The target JS API execution module is used to obtain the target JS API matching the target API name inside the Web page, and call and execute the target JS API based on the target parameter description information.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the communication method between a mobile application and a web page executed by a web page as described in any one of claims 1-5 or the communication method between a mobile application and a web page executed by a mobile application as described in any one of claims 6-7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, which are used to enable a processor to implement the communication method between a mobile application executed by a web page and a web page as described in any one of claims 1-5 or the communication method between a mobile application executed by a mobile application and a web page as described in any one of claims 6-7.