Methods and apparatus for interaction between applications and web pages
By calling the application programming interface (API) in the browser to receive and parse input parameters, the problem of insufficient stability and flexibility in the interaction between native applications and web pages is solved, achieving seamless interaction and efficient version management, and improving the stability and flexibility of the interaction between the browser and the application.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-23
- Publication Date
- 2026-03-13
AI Technical Summary
In existing technologies, the interaction methods between native applications and web pages lack stability and flexibility, and cannot effectively meet the needs of modern communication technologies.
By calling the application's interface in the browser, receiving input parameters, and parsing and running functions in the application, interaction between the browser and the application is achieved. Pre-encapsulated interaction code is used to improve the stability and flexibility of the interaction.
It enables seamless interaction between the browser and the application, supports asynchronous version upgrades, reduces errors, improves the stability and flexibility of the interaction, and enhances the fault tolerance of the client.
Smart Images

Figure CN115758026B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data processing technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for interaction between an application and a web page. Background Technology
[0002] With the development of computer technology, various application technologies (APPs) have emerged, bringing great convenience to people's production and life. However, with the development of communication technology, new application functions are constantly being updated, and native applications need to interact extensively with web pages. The demands for the stability and flexibility of transmission between native applications and web pages are increasing exponentially.
[0003] In related technologies, during the browser's webpage loading process, links to be loaded are intercepted and processed to achieve communication with the application. This method has parameter limitations; for example, only basic data types can be passed, limiting the transmission of excessive parameters, and it also poses security risks. Another related technology pre-registers each method requiring interaction in the application and listens for browser calls. This method is inflexible and difficult to maintain. Therefore, the stability and flexibility of existing interaction methods no longer meet real-world needs. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product that enables flexible and stable interaction between applications and web pages, addressing the aforementioned technical problems.
[0005] Firstly, this application provides a method for interaction between an application and a web page. The method includes:
[0006] The application's interface is invoked in the browser, and input parameters are received through the interface; wherein, the input parameters include at least the identifier of the function being invoked; the browser is a browser created in the application for displaying web pages;
[0007] Send the identifier of the interface and the input parameters to the application.
[0008] The application receives and parses the identifier of the interface and the input parameters, generates the method declaration of the interface, runs the calling function, and obtains the running result.
[0009] In one possible implementation, the input parameters further include an identifier for the callback function, and the step after obtaining the execution result further includes:
[0010] If the required execution result is determined, a callback function declaration is generated based on the identifier of the callback function;
[0011] Run the callback function to return the result to the browser.
[0012] In one possible implementation, running the callback function to return the execution result to the browser includes:
[0013] The identifier of the callback function and the execution result are concatenated into a string format;
[0014] The identifier of the concatenated callback function and the execution result are used as the input parameters of the callback function, and the callback function is executed in the browser.
[0015] In one possible implementation, sending the input parameters to the application includes:
[0016] The input parameters are converted into string format to obtain the input parameters in string format;
[0017] The input parameters in string format are sent to the application as a message.
[0018] In one possible implementation, receiving and parsing the identifier of the interface and the input parameters in the application includes:
[0019] The application receives the input parameters in the string format.
[0020] Convert the string-formatted input parameters into object-formatted input parameters;
[0021] Parse the input parameters in the object format to obtain the identifier of the interface, the identifier of the called function, and the identifier of the callback function.
[0022] In one possible implementation, the method declaration for generating the interface includes:
[0023] Generate a method selector corresponding to the interface based on the interface identifier;
[0024] The method selector is located in the application. If the method selector exists, the method declaration of the interface is generated.
[0025] In one possible implementation, pre-packaged first interactive code is loaded in the browser; wherein, the first interactive code is used at runtime for the browser to execute an interface that calls the application, receive input parameters using the interface, and send the identifier of the interface and the input parameters to the application.
[0026] Load pre-packaged second interaction code into the application; wherein, at runtime, the second interaction code is used by the application to receive and parse the identifier of the interface and the input parameters, generate the method declaration of the interface, run the calling function, and obtain the running result.
[0027] Secondly, this application also provides an interaction device between an application and a web page, characterized in that the device comprises:
[0028] A receiving module is used to call the application's interface in a browser and receive input parameters through the interface; wherein, the input parameters include at least the identifier of the called function; the browser is a browser created in the application for displaying web pages;
[0029] A sending module is used to send the identifier of the interface and the input parameters to the application.
[0030] The calling module is used to receive and parse the identifier of the interface and the input parameters in the application, generate the method declaration of the interface, run the calling function, and obtain the running result.
[0031] In one possible implementation, the input parameter further includes an identifier for a callback function, and the device further includes:
[0032] The generation module is used to generate a declaration of a callback function based on the identifier corresponding to the callback function, when it is determined that the running result is needed;
[0033] The callback module is used to run the callback function to return the running result to the browser.
[0034] In one possible implementation, the callback module includes:
[0035] The concatenation submodule is used to concatenate the identifier of the callback function and the execution result into a string format;
[0036] The callback submodule is used to take the identifier of the concatenated callback function and the running result as input parameters of the callback function, and run the callback function in the browser.
[0037] In one possible implementation, the sending module includes:
[0038] The conversion submodule is used to convert the input parameters into string format to obtain input parameters in string format;
[0039] The sending submodule is used to send the input parameters in string format to the application as a message.
[0040] In one possible implementation, the calling module includes:
[0041] A receiving submodule is used to receive the input parameters in the string format in the application.
[0042] The conversion submodule is used to convert the input parameters in string format into input parameters in object format;
[0043] The parsing submodule is used to parse the input parameters in the object format to obtain the identifier of the interface, the identifier of the called function, and the identifier of the callback function.
[0044] In one possible implementation, the calling module further includes:
[0045] The first generation submodule is used to generate a method selector corresponding to the interface based on the interface identifier;
[0046] The second generation submodule is used to search for the method selector in the application, and if the method selector exists, generate the method declaration of the interface.
[0047] One possible implementation also includes:
[0048] The first loading module is used to load pre-packaged first interactive code into the browser; wherein, when the first interactive code is run, it is used to enable the browser to execute an interface that calls the application, receive input parameters through the interface, and send the identifier of the interface and the input parameters to the application.
[0049] The second loading module is used to load pre-packaged second interactive code into the application; wherein, the second interactive code is used by the application to receive and parse the identifier of the interface and the input parameters, generate the method declaration of the interface, run the calling function, and obtain the running result.
[0050] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method as described in any of the embodiments of this disclosure.
[0051] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the method described in any of the embodiments of this disclosure.
[0052] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the method described in any of the embodiments of this disclosure.
[0053] The aforementioned methods, devices, computer equipment, storage media, and computer program products for interaction between applications and web pages, by setting up an interface in the browser to call the application and receiving input parameters through the interface, including functions called in the application, allow the browser and native application to interact without modifying existing code in the browser or native application. This enables asynchronous version upgrades of the browser or native application without affecting interactive use. Furthermore, when interaction with new functions in the application is required, unlike existing technologies that require registering new code in the application to implement the interaction function, this disclosure only needs to obtain the calling function of the new function and use that calling function as an input parameter, improving the stability and flexibility of the interaction between the browser and the application. Simultaneously, this disclosure reduces errors caused by multiple application releases, improving the client's fault tolerance. Attached Figure Description
[0054] Figure 1 This is a first flowchart illustrating a method for interaction between an application and a web page in one embodiment;
[0055] Figure 2 This is a second flowchart illustrating a method for interaction between an application and a web page in one embodiment;
[0056] Figure 3 This is a schematic diagram of the third process of an application interacting with a web page in one embodiment;
[0057] Figure 4 This is a schematic diagram of the fourth process of an application interacting with a web page in one embodiment;
[0058] Figure 5 This is a fifth flowchart illustrating the interaction method between an application and a web page in one embodiment;
[0059] Figure 6 This is a schematic diagram of the sixth process of an application interacting with a web page in one embodiment;
[0060] Figure 7 This is a schematic diagram of the seventh process of an application interacting with a web page in one embodiment;
[0061] Figure 8 This is a schematic diagram of the eighth process of the interaction method between an application and a web page in one embodiment;
[0062] Figure 9 This is a structural block diagram of an application's interaction device with a web page in one embodiment;
[0063] Figure 10 This is an internal structural diagram of a computer device in one embodiment;
[0064] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0065] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0066] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties. The acquisition, storage, use, and processing of data in this application's counting scheme all comply with the relevant provisions of national laws and regulations.
[0067] In one embodiment, such as Figure 1 As shown, a method for interaction between an application and a web page is provided, including the following steps:
[0068] Step S101: In the browser, call the application's interface and use the interface to receive input parameters; wherein, the input parameters include at least the identifier of the function being called; the browser is a browser created in the application for displaying web pages.
[0069] In this embodiment, a browser is created within the application to run HTML files and display web pages. The type of browser described in this embodiment is not limited, such as an H5 browser. In an exemplary embodiment, the application can run on iOS, Android, or Linux systems; this disclosure does not impose any limitations. In an exemplary embodiment, the browser can be configured to allow interaction with HTML. In an exemplary embodiment, an interactive function class can be created, containing an interface for calling the application. This interface can receive input parameters, including at least an identifier for the called function. The called function pre-exists within the application and corresponds to a data processing procedure within the application.
[0070] Step S103: Send the identifier of the interface and the input parameters to the application.
[0071] In this embodiment of the disclosure, the identifier of the interface and the input parameters can be sent to the application as a message, wherein the input parameters include at least the identifier of the called function. In an exemplary embodiment, for ease of transmission, the identifier of the interface and the input parameters can be converted into a preset format. For example, an object can be converted into a string.
[0072] Step S105: The application receives and parses the identifier of the interface and the input parameters, generates the method declaration of the interface, runs the calling function, and obtains the running result.
[0073] In this embodiment, a preset front-end message receiving object (preset program class) can be used to receive the identifier and input parameters of the interface. In an exemplary embodiment, the identifier and input parameters of the interface are parsed, and the preset format is converted into the original format for data processing. In this embodiment, the method declaration is used to describe the functions that the class should have, and may include, for example,: permission modifier return value type method name (parameter list) {method body}. The method declaration is used to execute the calling function in the class. In an exemplary embodiment, if the above interface does not exist in the application, a pop-up window can be used to indicate that the method does not exist. In an exemplary embodiment, if the passed parameter is a control, a prompt can be made: the corresponding parameter must be passed according to the convention.
[0074] In this embodiment, by setting an interface in the browser to call the application and receiving input parameters, including functions called in the application, the browser and native application can interact without modifying existing code in either the browser or the native application. This allows for asynchronous version upgrades of the browser or native application without affecting usability. Furthermore, when interacting with new functions in the application, unlike existing technologies that require registering new code in the application to implement the interaction, this embodiment only needs to know the calling function of the new function and use that function as an input parameter, improving the stability and flexibility of the interaction between the browser and the application. Simultaneously, this embodiment reduces errors caused by multiple application releases, improving the client's fault tolerance.
[0075] Figure 2 This is a second flowchart illustrating the interaction method between an application and a web page in one embodiment, with reference to... Figure 2 As shown, in step S105, the application receives and parses the identifier of the interface and the input parameters, generates the method declaration of the interface, runs the calling function, and obtains the running result. This is followed by:
[0076] Step S207: If it is determined that the running result is needed, generate the declaration of the callback function according to the identifier of the callback function.
[0077] Step S209: Run the callback function to return the running result to the browser.
[0078] In this embodiment, whether a running result is needed can be selected based on the specific interaction scenario. In one exemplary embodiment, a function call can be executed in the application to obtain the running result. In another exemplary embodiment, a callback function can be called in the application to send the running result to the browser. In this embodiment, the callback function includes functions existing in the front-end browser. In one exemplary embodiment, an identifier for the callback function can be added to the input parameters. For example, if the input parameter is callback function A, the running result will be returned through callback function A; if the input parameter is callback function B, the running result will be returned through callback function B.
[0079] This embodiment of the disclosure sends the execution result to the browser through a callback function, without modifying the code of the client's native application, thus improving the flexibility of interaction. Furthermore, the callback method in this embodiment is an asynchronous callback. Specifically, when the browser initiates a time-consuming task, the browser can simultaneously execute tasks that do not depend on the application's return result. Simultaneously, when the application finishes processing the task sent by the browser and obtains the execution result, it can promptly and accurately notify the browser. Upon receiving the processing notification, the browser then performs the next operation based on the execution result. This enables browser-application interaction without memory lag, improving processor smoothness.
[0080] Figure 3 This is a schematic diagram of the third process of an application's interaction with a web page in one embodiment, with reference to... Figure 3 As shown, step S209, running the callback function to return the running result to the browser, includes:
[0081] Step S301: Concatenate the identifier of the callback function and the running result into a string format.
[0082] Step S303: Use the identifier of the concatenated callback function and the running result as input parameters of the callback function, and run the callback function in the browser.
[0083] In this embodiment of the disclosure, the identifier of the callback function and the execution result are concatenated into a string format. In an exemplary embodiment, the data type of the execution result or other data may also be concatenated into the string. In this embodiment of the disclosure, the concatenation includes setting the identifier of the callback function and the string format of the execution result in a preset order, for example, the string format is: callback function declaration, execution result, execution result data type.
[0084] In this embodiment of the disclosure, the identifier of the concatenated callback function and the running result are used as input parameters of the callback function, and the callback function is run in the browser to obtain the running result.
[0085] In this embodiment, the identifier of the callback function and the execution result are concatenated. In other embodiments, more information can be concatenated, which can reduce the number of interactions and improve interaction efficiency.
[0086] Figure 4 This is a schematic diagram of the fourth process of an application's interaction method with a web page in one embodiment, referencing... Figure 4 As shown, step S105, sending the interface identifier and the input parameters to the application, includes:
[0087] Step S401: Convert the input parameters into string format to obtain input parameters in string format;
[0088] Step S403: Send the input parameters in string format to the application as a message.
[0089] In this embodiment of the disclosure, the input parameters are converted into string format, that is, the input parameters are processed as JSON objects. In an exemplary embodiment, the string-formatted input parameters can be sent to the application as a message. For example: message(JSON.string(params)).
[0090] In this embodiment, the input parameters are converted into strings and sent to the application as messages, which conforms to the existing WKScriptMessageHandle protocol and allows for greater compatibility of the interaction methods in this embodiment.
[0091] Figure 5 This is a fifth flowchart illustrating the interaction method between an application and a web page in one embodiment. (Refer to...) Figure 5 As shown, step S105, receiving and parsing the identifier of the interface and the input parameters in the application, includes:
[0092] Step S501: Receive the input parameters in the string format in the application.
[0093] Step S503: Convert the string-formatted input parameter into an object-formatted input parameter;
[0094] Step S505: Parse the input parameters of the object format to obtain the identifier of the interface, the identifier of the calling function, and the identifier of the callback function.
[0095] In this embodiment of the disclosure, a class can be set up in the application to receive messages. In an exemplary embodiment, when there are many messages, the messages can be cached in a message queue. When a message is received, the input parameters are extracted from the message and converted into object-formatted input parameters. In an exemplary embodiment, if the identifier of a callback function exists in the input parameters, it indicates that the execution result needs to be sent to the callback function. The method declaration of the interface is generated, the calling function is run, and the execution result is obtained.
[0096] In this embodiment of the disclosure, when a string-formatted input parameter is received, the function cannot be run immediately. It is necessary to convert the string-formatted input parameter into an object-formatted input parameter, and then run the function call to obtain the running result.
[0097] Figure 6 This is a sixth flowchart illustrating the interaction method between an application and a web page in one embodiment. (Refer to...) Figure 6 As shown, in step 105, the application receives and parses the identifier of the interface and the input parameters, generates the method declaration of the interface, runs the calling function, and obtains the running result, including:
[0098] Step S601: Receive and parse the identifier of the interface and the input parameters in the application, and generate a method selector corresponding to the interface based on the identifier of the interface.
[0099] Step S603: Search for the method selector in the application. If the method selector exists, generate the method declaration of the interface, run the calling function, and obtain the running result.
[0100] In this embodiment, the method selector is used to represent the address of a method. The method selector corresponding to the interface is searched within the application. In an exemplary embodiment, if no method selector is found, a pop-up message can be displayed indicating that the method has not yet been implemented. In an exemplary embodiment, if the method selector is found, a method declaration or method signature for the interface is generated. The method declaration or method signature is a unique identifier for the method; its existence indicates the existence of a concrete implementation of the method.
[0101] In this embodiment of the disclosure, a method selector corresponding to the interface is generated, and the method selector is searched in the application. If the method selector exists in the application, it means that the method exists. This embodiment of the disclosure can quickly determine whether the method corresponding to the interface exists in the application.
[0102] Figure 7 This is a schematic diagram of the seventh process of an application's interaction method with a web page in one embodiment, referencing... Figure 7 As shown, in step S101, the application's interface is called in the browser to receive input parameters; wherein, the input parameters include at least the identifier of the called function; the browser is a browser created in the application for displaying web pages, and the preceding steps also include:
[0103] Step S701: Load pre-packaged first interactive code in the browser; wherein, the first interactive code is used at runtime to allow the browser to execute an interface that calls the application, receive input parameters using the interface, and send the identifier of the interface and the input parameters to the application.
[0104] Step S703: Load pre-packaged second interaction code into the application; wherein, the second interaction code is used at runtime for the application to receive and parse the identifier of the interface and the input parameters, generate the method declaration of the interface, run the calling function, and obtain the running result.
[0105] In this embodiment, for different clients, the first interaction code and the second interaction code can be obtained through loading. In an exemplary embodiment, the first interaction code is used at runtime for the browser to execute and call the application's interface, receive input parameters using the interface, and send the interface's identifier and the input parameters to the application. In other exemplary embodiments, the first interaction code may further include pre-encapsulated browser execution steps from the above embodiments. In an exemplary embodiment, the second interaction code is used at runtime for the application to receive and parse the interface's identifier and the input parameters, generate the interface's method declaration, run the calling function, and obtain the execution result. In other exemplary embodiments, the second interaction code may further include pre-encapsulated application execution steps from the above embodiments. In an exemplary embodiment, a response class can also be added to the browser to handle messages sent to the client.
[0106] In this embodiment of the disclosure, by encapsulating the first interaction code and the second interaction code, the interaction method can be dynamically called by loading during program execution without requiring significant modifications to the source code, thus improving the applicability of the interaction method.
[0107] Figure 8 This is a schematic diagram of the eighth process of an application's interaction with a web page in one embodiment. (See reference...) Figure 8 As shown, when the client launches the application (APP), it opens the browser (webView) and proceeds to step 801. The first interactive code (JS calling method) is injected into the browser, and the second interactive code (calling JS method) is injected into the application. If injection fails during this process, a pop-up window will indicate that the method does not exist. Step 803: After the interactive code injection is complete, the front-end (browser) calls the first interactive code, using an interface (such as requestNative) to receive the agreed-upon input parameters. If the parameters are empty, the front-end will be prompted to pass in the agreed-upon parameters. Step 805: The client (application) parses the input parameters and, based on the input parameters, generates the method declaration of the interface through runtime, calling the calling function in the input parameters. If the call fails, it will indicate that the interface functionality has not yet been developed. Step 807: The called function implements the corresponding logic, determining whether a callback result (running result) is needed based on whether a callback function exists in the input parameters. Step 809: Based on the name (identifier) of the callback function in the input parameters, a callback function declaration is generated, the callback function is called, and the call ends, completing the round-trip interaction between the browser and the application.
[0108] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0109] Based on the same inventive concept, this application also provides an application-webpage interaction device for implementing the above-described application-webpage interaction method. The solution provided by this device is similar to the implementation described in the above-described method. Therefore, the specific limitations of one or more application-webpage interaction device embodiments provided below can be found in the limitations of the application-webpage interaction method described above, and will not be repeated here.
[0110] In one embodiment, Figure 9 This is a structural block diagram of an application's interaction device with a web page in one embodiment, with reference to... Figure 9 As shown, the device 900 includes:
[0111] The receiving module 901 is used to call the application's interface in the browser and receive input parameters through the interface; wherein, the input parameters include at least the identifier of the called function; the browser is a browser created in the application and used to display web pages;
[0112] The sending module 903 is used to send the identifier of the interface and the input parameters to the application program;
[0113] The calling module 905 is used to receive and parse the identifier of the interface and the input parameters in the application, generate the method declaration of the interface, run the calling function, and obtain the running result.
[0114] In one possible implementation, the input parameter further includes an identifier for a callback function, and the device further includes:
[0115] The generation module is used to generate a declaration of a callback function based on the identifier corresponding to the callback function, when it is determined that the running result is needed;
[0116] The callback module is used to run the callback function to return the running result to the browser.
[0117] In one possible implementation, the callback module includes:
[0118] The concatenation submodule is used to concatenate the identifier of the callback function and the execution result into a string format;
[0119] The callback submodule is used to take the identifier of the concatenated callback function and the running result as input parameters of the callback function, and run the callback function in the browser.
[0120] In one possible implementation, the sending module includes:
[0121] The conversion submodule is used to convert the input parameters into string format to obtain input parameters in string format;
[0122] The sending submodule is used to send the input parameters in string format to the application as a message.
[0123] In one possible implementation, the calling module includes:
[0124] A receiving submodule is used to receive the input parameters in the string format in the application.
[0125] The conversion submodule is used to convert the input parameters in string format into input parameters in object format;
[0126] The parsing submodule is used to parse the input parameters in the object format to obtain the identifier of the interface, the identifier of the called function, and the identifier of the callback function.
[0127] In one possible implementation, the calling module further includes:
[0128] The first generation submodule is used to generate a method selector corresponding to the interface based on the interface identifier;
[0129] The second generation submodule is used to search for the method selector in the application, and if the method selector exists, generate the method declaration of the interface.
[0130] One possible implementation also includes:
[0131] The first loading module is used to load pre-packaged first interactive code into the browser; wherein, when the first interactive code is run, it is used to enable the browser to execute an interface that calls the application, receive input parameters through the interface, and send the identifier of the interface and the input parameters to the application.
[0132] The second loading module is used to load pre-packaged second interactive code into the application; wherein, the second interactive code is used by the application to receive and parse the identifier of the interface and the input parameters, generate the method declaration of the interface, run the calling function, and obtain the running result.
[0133] The modules in the aforementioned application and webpage interaction device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of the computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0134] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores interactive data between the application program and web pages. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a method for interaction between the application program and a web page.
[0135] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 11 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements an application program's interaction method with a web page. The display screen can be an LCD screen or an e-ink display screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad located on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0136] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0137] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0138] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0139] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0140] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. An application interacting with a web page method, characterized in that, The method comprises: loading a pre-packaged first interaction code in a browser; wherein the first interaction code is used for the browser to execute an interface of an application program, receive an input parameter by using the interface, and send an identification of the interface and the input parameter to an application program at runtime; calling an interface of an application program in a browser, and receiving an input parameter by using the interface; wherein the input parameter at least comprises an identification of a calling function; the browser is a browser created in the application program, and is used for displaying a web page; sending the identification of the interface and the input parameter to the application program in the form of a message; receiving the identification of the interface and the input parameter by using a preset front-end message receiving object in the application program, analyzing the identification of the interface and the input parameter, generating a method declaration of the interface, running the calling function, and obtaining a running result.
2. The method of claim 1, wherein, The input parameter further comprises an identification of a callback function, and after the running result is obtained, the following steps are further included: generating a declaration of the callback function according to the identification corresponding to the callback function in a case where it is determined that the running result is needed; running the callback function to return the running result to the browser.
3. The method of claim 2, wherein, The running of the callback function to return the running result to the browser comprises: splicing the identification of the callback function and the running result into a string format; taking the spliced identification of the callback function and the running result as input parameters of the callback function, and running the callback function.
4. The method of claim 1, wherein, The sending of the input parameter to the application program comprises: converting the input parameter into a string format to obtain an input parameter in a string format; sending the input parameter in the string format to the application program in the form of a message.
5. The method of claim 4, wherein, The receiving and analyzing of the identification of the interface and the input parameter in the application program comprises: receiving the input parameter in the string format in the application program; converting the input parameter in the string format into an input parameter in an object format; analyzing the input parameter in the object format to obtain the identification of the interface, the identification of the calling function, and the identification of the callback function.
6. The method of claim 1, wherein, The generation of the method declaration of the interface comprises: generating a method selector corresponding to the interface according to the identification of the interface; finding the method selector in the application program, and generating a method declaration of the interface if the method selector exists.
7. The method of any one of claims 1 to 6, characterized in that: Further comprising: loading a pre-packaged second interaction code in an application program; wherein the second interaction code is used for the application program to receive and analyze the identification of the interface and the input parameter, generate a method declaration of the interface, run the calling function, and obtain a running result at runtime.
8. An interactive device for an application and a web page, characterized in that, The apparatus comprises: a first loading module configured to load a pre-packaged first interaction code in a browser; wherein the first interaction code is used for the browser to execute an interface of an application program, receive an input parameter by using the interface, and send an identification of the interface and the input parameter to an application program at runtime; The receiving module is configured to call an interface of an application in a browser, and receive input parameters by using the interface, wherein the input parameters at least include an identifier of a calling function; the browser is a browser created in the application and used to display a web page; The sending module is configured to send the identifier of the interface and the input parameters to the application in a message manner; The calling module is configured to receive the identifier of the interface and the input parameters by using a preset front-end message receiving object in the application, parse the identifier of the interface and the input parameters, generate a method declaration of the interface, run the calling function, and obtain a running result.
9. The apparatus of claim 8, wherein, The input parameters further include an identifier of a callback function, and the apparatus further includes: The generating module is configured to generate a declaration of the callback function according to the identifier corresponding to the callback function in a case where it is determined that the running result is needed; The callback module is configured to run the callback function to return the running result to the browser.
10. The apparatus of claim 9, wherein, The callback module includes: The concatenating submodule is configured to concatenate the identifier of the callback function and the running result into a string format; The callback submodule is configured to take the concatenated identifier of the callback function and the running result as input parameters of the callback function, and run the callback function in the browser.
11. The apparatus of claim 8, wherein, The sending module includes: The converting submodule is configured to convert the input parameters into a string format to obtain input parameters in a string format; The sending submodule is configured to send the input parameters in the string format to the application in a message manner.
12. The apparatus of claim 11, wherein, The calling module includes: The receiving submodule is configured to receive the input parameters in the string format in the application; The converting submodule is configured to convert the input parameters in the string format into input parameters in an object format; The parsing submodule is configured to parse the input parameters in the object format to obtain the identifier of the interface, the identifier of the calling function, and the identifier of the callback function.
13. The apparatus of claim 8, wherein, The calling module further includes: The first generating submodule is configured to generate a method selector corresponding to the interface according to the identifier of the interface; The second generating submodule is configured to find the method selector in the application, and generate a method declaration of the interface if the method selector exists.
14. The apparatus of any one of claims 8-13, wherein, Further includes: The second loading module is configured to load a second pre-packaged interaction code in the application; wherein the second interaction code is used to receive and parse the identifier of the interface and the input parameters, generate a method declaration of the interface, run the calling function, and obtain a running result when the second interaction code is run.
15. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to implement the steps of the method in any one of claims 1 to 7.
16. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 7.
17. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 7.
Citation Information
Patent Citations
Application interaction method and device, computer equipment and storage medium
CN113076151A
Data interaction method and device, storage medium and electronic equipment
CN114090134A