Webpage and native function unit interaction method and device, equipment and medium

By building component communication unit and data interaction channel, registering native functional units and subscribing messages, the coupling problem between web pages and native functional units is solved, independent development and maintenance is realized, and seamless data flow with multi-window functions is supported.

CN119105886APending Publication Date: 2024-12-10PING AN INT FINANCIAL LEASING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411252256.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

In the prior art, the interaction method between web pages and native functional units is implemented through the JSBridge interface, resulting in strong coupling between codes, increasing the difficulty of development and maintenance of applications in complex scenarios, especially in multi-functional applications such as financial software. middle.

Method used

By obtaining component communication standards between the target web page and the native functional unit, building component communication units, establishing first and second data interaction channels, registering native functional units and subscribing to messages, realizing the solution between the web page and the native functional unit Coupled interaction.

Benefits of technology

The coupling degree between web pages and native functions is reduced, so that each native functional unit can be independently developed and maintained, achieving seamless data flow and instant transmission, and supporting multi-window functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119105886A_ABST
    Figure CN119105886A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an interaction method and device of a webpage and a native function unit, electronic equipment and a storage medium, and belongs to the technical field of distributed deployment and artificial intelligence. The method comprises the following steps: acquiring a component communication standard between a target webpage page and a preset native function unit; constructing a component communication unit based on the component communication standard; constructing a first data interaction channel between the component communication unit and the target webpage and a second data interaction channel between the component communication unit and the native function unit; based on the second data interaction channel, registering the native function unit to obtain a registered function component; based on the first data interaction channel, performing message subscription on the target webpage to obtain a message monitoring channel; and when the target web page sends a function calling request to the native function unit, interacting the target web page and the native function unit based on the channel. According to the embodiment of the invention, the coupling degree between the webpage in the application program and the original can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of distributed deployment and artificial intelligence technology, and in particular to a method and device for interaction between a web page and a native functional unit, an electronic device, and a storage medium. Background Art

[0002] In an application, the interaction between a web page and a native functional unit is essential. At present, the common method of interacting between a web page and a native functional unit is implemented by calling the JSBridge (script bridge, JavaScript Bridge) interface. However, the JSBridge interface usually injects functions into the global namespace to interact with the web page, resulting in a strong coupling between the web page and the code of the native function, which increases the difficulty of developing and maintaining the native functions in the application in complex scenarios. For example, in the financial field, it is often necessary to build a multifunctional financial software that can provide customers with the purchase of financial products, view stock trends, view financial consultations, etc. If the interaction between each function in the financial software and the web page is realized by calling the JSBridge interface, the development and maintenance difficulty of the functional modules in the financial software will increase. Therefore, how to reduce the coupling between the web page and the native function in the application has become a technical problem that needs to be solved urgently. Summary of the invention

[0003] The main purpose of the embodiments of the present application is to provide a method and device for interaction between a web page and a native functional unit, an electronic device and a storage medium, aiming to reduce the coupling between the web page and the native in an application.

[0004] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a method for interaction between a web page and a native functional unit, the method comprising:

[0005] Acquire a component communication standard between a target web page and a preset native functional unit;

[0006] Based on the component communication standard, construct a component communication unit between the target web page and the native function unit;

[0007] Establishing a first data interaction channel between the component communication unit and the target web page, and a second data interaction channel between the component communication unit and the native function unit;

[0008] Based on the second data interaction channel, registering the native function unit to the component communication unit to obtain a registered function component;

[0009] Based on the first data interaction channel and the component communication unit, subscribe to the target web page for messages to obtain a message monitoring channel;

[0010] When the target web page sends a function call request to the native function unit, the target web page and the native function unit interact based on the first data interaction channel, the second data interaction channel and the message monitoring channel.

[0011] In some embodiments, the component communication standard includes a communication event name and a communication data format, and the component communication unit between the target web page and the native function unit is constructed based on the component communication standard, including:

[0012] Determining a communication unit management event between the target web page and the native functional unit based on the communication event name;

[0013] Building an event management component based on the communication unit management event;

[0014] Based on the communication data format, construct a data transmission interface;

[0015] The event management component and the data transmission interface are combined to obtain the component communication unit.

[0016] In some embodiments, when the target web page sends a function call request to the native function unit, the target web page and the native function unit are interacted based on the first data interaction channel, the second data interaction channel and the message monitoring channel, including:

[0017] When the target web page sends a function call request to the native function unit, based on the message monitoring channel, information of the function call request is received to obtain a web page request;

[0018] Based on the second data interaction channel and the registration function component, respond to the webpage request to obtain function call feedback;

[0019] Based on the first data interaction channel and the function call feedback, a feedback request is made to the target web page to obtain communication interaction information between the target web page and the native function unit.

[0020] In some embodiments, the step of responding to the webpage request based on the second data interaction channel and the registration function component to obtain function call feedback includes:

[0021] Based on the second data interaction channel and the component communication unit, the web page request is transmitted to the registration function component to obtain a target request;

[0022] Based on the registration function component, the target request is parsed to obtain interaction data;

[0023] Based on the target request, the interactive data is data encapsulated to obtain the function call feedback.

[0024] In some embodiments, registering the native function unit to the component communication unit based on the second data interaction channel to obtain a registered function component includes:

[0025] Defining a registration interface for the component communication unit to obtain a functional component registration interface;

[0026] Based on the native functional unit, a registration method is defined for the component communication unit to obtain a functional component registration method;

[0027] Based on the functional component registration method and the component communication unit, construct a component registration request;

[0028] Based on the native functional unit and the second data interaction channel, the component registration request is sent to the functional component registration interface of the component communication unit to obtain the registered functional component.

[0029] In some embodiments, the native function unit includes a function name, a function description, and a function event type, and the registering method definition of the component communication unit based on the native function unit and the second data interaction channel to obtain the function component registration method includes:

[0030] Based on the function name, label the native function unit to obtain a function identifier;

[0031] Determining function information of the native function unit based on the function description and the function event type;

[0032] The function identifier and the function information are merged to obtain the function component registration method.

[0033] In some embodiments, the subscribing to a message of the target web page based on the first data interaction channel and the component communication unit to obtain a message monitoring channel includes:

[0034] Based on the component communication unit and the first data interaction channel, sending a message subscription request to the target web page;

[0035] Based on the target web page, respond to the message subscription request to obtain message subscription feedback data;

[0036] Creating a page message listener for the target web page based on the first data interaction channel and the message subscription response;

[0037] The page message listener is registered in the component communication unit to obtain the message monitoring channel.

[0038] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides an interactive device for a web page and a native functional unit, the device comprising:

[0039] A communication standard acquisition module, used to acquire the component communication standard between the target web page and the preset native functional unit;

[0040] A dispatch center construction module, used to construct a component communication unit between the target web page and the native function unit based on the component communication standard;

[0041] An interactive channel construction module, used to construct a first data interactive channel between the component communication unit and the target web page, and a second data interactive channel between the component communication unit and the native function unit;

[0042] A function unit registration module, used to register the native function unit with the component communication unit based on the second data interaction channel to obtain a registered function component;

[0043] A monitoring channel construction module, used to subscribe to a message of the target web page based on the first data interaction channel and the component communication unit to obtain a message monitoring channel;

[0044] The page function interaction module is used to interact the target web page and the native function unit based on the first data interaction channel, the second data interaction channel and the message monitoring channel when the target web page sends a function call request to the native function unit.

[0045] To achieve the above objectives, a third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.

[0046] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.

[0047] The method and device for interacting with a web page and a native functional unit, an electronic device, and a storage medium proposed in the present application, construct a component communication unit between a target web page and a native functional unit by acquiring a component communication standard between the target web page and a preset native functional unit, so that data between multiple target web pages and multiple native functional units can flow seamlessly, thereby realizing multi-window support. Furthermore, a first data interaction channel between the component communication unit and the target web page and a second data interaction channel between the component communication unit and the native functional unit are constructed, which can improve the immediacy of data transmission between the web page, the native functional unit, and the component communication unit. Secondly, According to the second data interaction channel, the native function unit is registered with the component communication unit to obtain the registered function component, and according to the first data interaction channel and the component communication unit, the target web page is subscribed to messages to obtain the message monitoring channel, which reduces the coupling between the web page and the native function in the application, so that each native function unit can be independently developed and maintained. Finally, when the target web page sends a function call request to the native function unit, the target web page and the native function unit are interacted based on the first data interaction channel, the second data interaction channel and the message monitoring channel, which can ensure that the target web page and the native function unit are decoupled and the data can flow seamlessly. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 is a flow chart of a method for interacting a web page with a native functional unit provided in an embodiment of the present application;

[0049] Figure 2 yes Figure 1 Flow chart of step S102 in FIG.

[0050] Figure 3 yes Figure 1 Flow chart of step S104 in FIG.

[0051] Figure 4 yes Figure 3 Flow chart of step S302 in FIG.

[0052] Figure 5 yes Figure 1 Flow chart of step S105 in FIG.

[0053] Figure 6 yes Figure 1 Flow chart of step S106 in FIG.

[0054] Figure 7 yes Figure 6 Flowchart of step S602 in FIG.

[0055] Figure 8It is a structural schematic diagram of an interactive device between a web page and a native functional unit provided in an embodiment of the present application;

[0056] Fig. 9 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0057] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0058] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0060] First, some nouns involved in this application are analyzed:

[0061] Web page: A web page is a single document or information unit accessed through a web browser, usually composed of technologies such as hypertext markup language, cascading style sheets and script files. A web page can contain a variety of media content such as text, images, videos, audio, etc., and can be connected to other web pages through links. It is the basic unit for Internet content display and information interaction. Users access and browse different web pages by entering a uniform resource locator address or clicking a link. Web pages can not only present static information, but also enrich the user experience through dynamic content and interactive functions.

[0062] In an application, the interaction between a web page and a native functional unit is essential. At present, the common method of interacting between a web page and a native functional unit is implemented by calling the JSBridge (script bridge, JavaScript Bridge) interface. However, the JSBridge interface usually injects functions into the global namespace to interact with the web page, resulting in a strong coupling between the web page and the code of the native function, which increases the difficulty of developing and maintaining the native functions in the application in complex scenarios. For example, in the financial field, it is often necessary to build a multifunctional financial software that can provide customers with the purchase of financial products, view stock trends, view financial consultations, etc. If the interaction between each function in the financial software and the web page is realized by calling the JSBridge interface, the development and maintenance difficulty of the functional modules in the financial software will increase. Therefore, how to reduce the coupling between the web page and the native function in the application has become a technical problem that needs to be solved urgently.

[0063] Based on this, the embodiments of the present application provide a method and device for interaction between a web page and a native functional unit, an electronic device and a storage medium, aiming to reduce the coupling between the web page and the native in the application.

[0064] The interaction method and device, electronic device and storage medium between a web page and a native functional unit provided in the embodiments of the present application are specifically described through the following embodiments. First, the interaction method between a web page and a native functional unit in the embodiments of the present application is described.

[0065] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0066] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0067] The interactive method between a web page and a native functional unit provided in the embodiment of the present application relates to the field of distributed deployment and artificial intelligence technology. The interactive method between a web page and a native functional unit provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server side, and can also be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the interactive method between a web page and a native functional unit, etc., but is not limited to the above forms.

[0068] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0069] Figure 1 is an optional flow chart of the method for interacting a web page with a native functional unit provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S106.

[0070] Step S101, obtaining a component communication standard between a target web page and a preset native functional unit;

[0071] Step S102, constructing a component communication unit between the target web page and the native function unit based on the component communication standard;

[0072] Step S103, constructing a first data interaction channel between the component communication unit and the target web page, and a second data interaction channel between the component communication unit and the native function unit;

[0073] Step S104, based on the second data interaction channel, registering the native functional unit to the component communication unit to obtain a registered functional component;

[0074] Step S105, based on the first data interaction channel and the component communication unit, subscribe to the target web page for messages to obtain a message monitoring channel;

[0075] Step S106, when the target web page sends a function call request to the native function unit, the target web page and the native function unit are interacted based on the first data interaction channel, the second data interaction channel and the message monitoring channel.

[0076] In steps S101 to S106 shown in the embodiment of the present application, a component communication standard between a target web page and a preset native function unit is obtained to construct a component communication unit between the target web page and the native function unit, and then a first data interaction channel between the component communication unit and the target web page and a second data interaction channel between the component communication unit and the native function unit are constructed. Secondly, according to the second data interaction channel, the native function unit is registered with the component communication unit to obtain a registered function component. According to the first data interaction channel and the component communication unit, a message subscription is performed on the target web page to obtain a message monitoring channel. Finally, when the target web page sends a function call request to the native function unit, the target web page and the native function unit are interacted with based on the first data interaction channel, the second data interaction channel and the message monitoring channel. Therefore, the present application constructs a component communication unit between the target web page and the native function unit by acquiring the component communication standard between the target web page and the preset native function unit, so that the data between multiple target web pages and multiple native function units can flow seamlessly, thereby realizing multi-window support. Furthermore, a first data interaction channel between the component communication unit and the target web page, and a second data interaction channel between the component communication unit and the native function unit are constructed, which can improve the immediacy of data transmission between the web page, the native function unit and the component communication unit. Secondly, according to the second data interaction channel, the native function unit is registered with the component communication unit to obtain a registered function component, and according to the first data interaction channel and the component communication unit, the target web page is subscribed to a message to obtain a message listening channel, which reduces the coupling between the web page and the native function in the application, so that each native function unit can be independently developed and maintained. Finally, when the target web page sends a function call request to the native function unit, based on the first data interaction channel, the second data interaction channel and the message listening channel, the target web page and the native function unit are interacted, which can ensure that the target web page and the native function unit can flow seamlessly when decoupled.

[0077] In step S101 of some embodiments, the target web page refers to a single document or information unit accessed through a web browser, which is usually composed of technologies such as hypertext markup language, cascading style sheets and scripts. The native function unit can be a function built into an application or communication device. For example, a camera is one of the native function units of a communication device. It should be noted that the native function unit includes information such as a function name, a function description, and a function event type, wherein the function name refers to the name definition of the native function unit in the application or communication device, the function description refers to the description of the role played by the native function unit, and the function event type refers to the type of event corresponding to the function in the native function unit, so as to ensure that the unit in the native function unit can be called when the relevant event is received. The component communication standard refers to the communication event name and communication data format when the target web page and the native function unit communicate and interact, wherein the communication event name refers to the event name of the target web page sending a request to the native function unit or the native function unit sending a request to the target web page, and the communication data format refers to the format of the request data when the target web page sends a request to the native function unit or the native function unit sends a request to the target web page.

[0078] The present application can clarify the component communication standard between the target web page and the native function unit by combining and organizing the communication event names and communication data formats between the target web page and the native function.

[0079] In step S102 of some embodiments, the component communication unit may be a system for coordinating and managing the target web page and the native function unit.

[0080] The present application can construct an event management component for managing communication events between a target web page and a native functional unit according to the communication event name obtained in the component communication standard, and then construct a data transmission interface for transmitting data to the target web page and the native functional unit according to the communication data format in the component communication standard, and then assemble the above-mentioned event management component and the data transmission interface to obtain a component communication unit for coordinating and managing the target web page and the native functional unit.

[0081] For details, see Figure 2 In some embodiments, step S102 may include but is not limited to steps S201 to S204:

[0082] Step S201, determining a communication unit management event between a target web page and a native functional unit based on a communication event name;

[0083] Step S202, constructing an event management component based on the communication unit management event;

[0084] Step S203, constructing a data transmission interface based on the communication data format;

[0085] Step S204, merging the event management component and the data transmission interface to obtain a component communication unit.

[0086] In step S201 of some embodiments, the communication event that needs to be managed by the component communication unit to be constructed, ie, the communication unit management event, can be clearly identified based on the name of the communication event between the target web page and the native functional unit.

[0087] In step S202 of some embodiments, a component is constructed according to the determined communication unit management event for managing the communication unit management event, so that an event management component can be obtained.

[0088] In step S203 of some embodiments, an interface is defined according to the communication data format between the target web page and the native functional unit to obtain a data transmission interface for data transmission with the target web page and the native functional unit.

[0089] In step S204 of some embodiments, the event management component and the data transmission interface are assembled into components to obtain a component communication unit for coordinating and managing the target web page and the native function unit.

[0090] In steps S201 to S204 shown in this embodiment, an event management component is constructed according to the communication event name in the component communication standard, and then a data transmission interface is constructed according to the communication data format in the component communication standard. The event management component and the data transmission interface are merged to obtain a component communication unit, which can achieve coordination and management of the target web page and the native functional unit.

[0091] In step S103 of some embodiments, according to the above-mentioned data transmission interface, a first data interaction channel between the component communication unit and the target web page, and a second data interaction channel between the component communication unit and the native function unit are respectively constructed to facilitate convenient communication between the target web page and the native function unit through the component communication unit.

[0092] In step S104 of some embodiments, an interface for registering a native functional unit is defined on the component communication unit to obtain a functional component registration interface, and then the functional information of the native functional unit is transmitted to the component communication unit through a second data interaction channel and the functional component registration interface, thereby registering the native functional unit to the component communication unit and obtaining a registered functional component.

[0093] For details, see Figure 3In some embodiments, step S104 may include but is not limited to steps S301 to S304:

[0094] Step S301, define the registration interface of the component communication unit to obtain the functional component registration interface;

[0095] Step S302, based on the native functional unit, define a registration method for the component communication unit to obtain a functional component registration method;

[0096] Step S303, constructing a component registration request based on the functional component registration method and the component communication unit;

[0097] Step S304: Based on the native functional unit and the second data interaction channel, a component registration request is sent to the functional component registration interface of the component communication unit to obtain a registered functional component.

[0098] In step S301 of some embodiments, some interfaces on the component communication unit are defined as interfaces for native functional unit registration, so that the functional component registration interface can be obtained.

[0099] In step S302 of some embodiments, the registration method is a mechanism in the application for the native functional unit to register its existence and properties with the component communication unit, thereby allowing the component communication unit to grasp the status and information of each native functional unit so that the component communication unit can effectively schedule and manage each native functional unit.

[0100] The present application transmits the state and information of the native functional unit to the component communication unit to implement the definition of the registration method in the component communication unit, thereby obtaining the functional component registration method of the native functional unit.

[0101] For details, see Figure 4 In some embodiments, step S302 may include but is not limited to steps S401 to S403:

[0102] Step S401, labeling the native functional unit based on the functional name to obtain a functional identifier;

[0103] Step S402, determining the function information of the native function unit based on the function description and the function event type;

[0104] Step S403: merge the function identifier and the function information to obtain a function component registration method.

[0105] In step S401 of some embodiments, the identifier of the native functional unit in the component communication unit is determined according to the functional name of the native functional unit, and the native functional unit is identified according to the identifier to obtain a functional identifier.

[0106] In step S402 of some embodiments, the functional role of the native functional unit and the event type to which the native functional unit responds can be obtained according to the functional description and the functional event type, thereby determining the functional information of the native functional unit.

[0107] In step S403 of some embodiments, the above-mentioned function identifier and function information are combined to obtain a digitized representation of the function information of the native function unit, that is, a function component registration method.

[0108] In steps S401 to S403 shown in the present embodiment, the native function unit is identified to determine the function identifier of the native function unit, and the function information of the native function unit is determined according to the function description and the function event type. The above function identifier and function information are then merged to obtain the status and information of the native function, thereby clarifying the component registration method of the native function unit and enabling the scheduling and management of each native function unit by the component communication unit.

[0109] In step S303 of some embodiments, after obtaining the functional component registration method, the native functional unit obtains a component registration request by sending a request including the status data and information data in the functional component registration method to the component communication unit.

[0110] In step S304 of some embodiments, the component registration request is sent to the component communication unit through the native function unit and the second data interaction channel between the native function unit and the component communication unit, and when the component communication unit agrees to the component registration request, the native function unit can be registered with the component communication unit to obtain a registered function component.

[0111] In steps S301 to S304 shown in the present embodiment, by defining a functional component registration interface and a functional component registration method of a native functional unit in the component communication unit, it is ensured that the native functional unit can be registered in the component communication unit. Furthermore, a component registration request is sent to the component communication unit by the native functional unit, and when the component communication unit agrees to the component registration request, the native functional unit is registered in the component communication unit, so as to realize effective scheduling and management of each native functional unit.

[0112] In step S105 of some embodiments, according to the first data interaction channel between the component communication unit and the target web page, the component communication unit is used to send a message subscription request to the target web page, and after the target web page agrees to the request, a message listening channel is generated for the component communication unit to receive the request message of the target web page.

[0113] For details, see Figure 5In some embodiments, step S105 may include but is not limited to steps S501 to S504:

[0114] Step S501, based on the component communication unit and the first data interaction channel, sending a message subscription request to the target web page;

[0115] Step S502, responding to the message subscription request based on the target web page to obtain message subscription feedback data;

[0116] Step S503, creating a page message listener of the target web page based on the first data interaction channel and the message subscription response;

[0117] Step S504: register the page message listener in the component communication unit to obtain a message monitoring channel.

[0118] In step S501 of some embodiments, request data for subscribing to a message of a target web page is generated by a component communication unit to obtain a message subscription request, which is then transmitted to the target web page through a first data interaction channel.

[0119] In step S502 of some embodiments, after the target web page receives the message subscription request, the message subscription request is parsed to clarify the purpose of the component communication unit, and the component communication unit is evaluated to determine whether the component communication unit meets the conditions for message subscription. If the component communication unit meets the conditions for message subscription, message subscription feedback data is generated to indicate that the message subscription request is successful.

[0120] In step S503 of some embodiments, the message subscription feedback data indicating a successful message subscription request is transmitted to the component communication unit through the first data interaction channel. After receiving the message subscription feedback data, the component communication unit creates a component for monitoring messages of the target web page to obtain a page message listener.

[0121] In step S504 of some embodiments, by registering the page message listener in the component communication unit, effective scheduling and management of the page message listener by the component communication unit can be achieved.

[0122] Specifically, the method of registering the page message listener in the component communication unit to obtain the message listening channel is similar to the method of registering the native function unit in the component communication unit to obtain the registered function component, so it is not repeated here.

[0123] In steps S501 to S504 shown in the present embodiment, the component communication unit sends a message subscription request to the target web page, and after receiving message subscription feedback data indicating the success of the message subscription request, builds a page message listener, and then registers the page message listener in the component communication unit to obtain a message monitoring channel, which enables the component communication unit to monitor the message of the target web page, so that the message sent by the target web page to the native function unit is obtained by the component communication unit and transmitted to the registered function component, thereby achieving decoupling between the native function unit and the target web page, reducing the code correlation between the native function unit and the target web page, and enabling the native function unit to be independently developed and maintained.

[0124] In step S106 of some embodiments, the component communication unit uses a message monitoring channel to monitor the target web page in real time, and when it monitors that the target web page sends a function call request to the native function unit, the communication interaction between the target web page and the native function unit is realized through the first data interaction channel and the second data interaction channel.

[0125] For details, see Figure 6 In some embodiments, step S106 may include but is not limited to steps S601 to S603:

[0126] Step S601, when the target web page sends a function call request to the native function unit, based on the message monitoring channel, the function call request is received to obtain a web page request;

[0127] Step S602: Based on the second data interaction channel and the registration function component, respond to the web page request and obtain function call feedback;

[0128] Step S603: Based on the first data interaction channel and the function call feedback, a request feedback is made to the target web page to obtain communication interaction information between the target web page and the native function unit.

[0129] In step S601 of some embodiments, when the target web page sends a function call request to the native function unit, the component communication unit may receive the function call request through the message monitoring channel to obtain a web page request from the target web page.

[0130] In step S602 of some embodiments, the component communication unit transmits the web page request to the registration function component through the second data interaction channel, and the registration function component responds according to the request information in the web page request to obtain function call feedback.

[0131] It is important to know that the function call feedback can indicate that the web page request is successful or unsuccessful. If the function call feedback indicates that the web page request is successful, the communication interaction between the target web page and the native functional unit is successfully achieved. If the function call feedback indicates that the web page request fails, the component communication unit regards the communication interaction between the target web page and the native functional unit as an abnormal situation when receiving the function call feedback, and performs abnormal processing on the communication interaction according to a pre-set abnormal situation processing method, for example, responding to the abnormal situation with an error report and other abnormal situation processing methods.

[0132] For details, see Figure 7 In some embodiments, step S602 may include but is not limited to steps S701 to S703:

[0133] Step S701, based on the second data interaction channel and the component communication unit, the web page request is transmitted to the registration function component to obtain the target request;

[0134] Step S702, based on the registration function component, the target request is parsed to obtain interaction data;

[0135] Step S703: based on the target request, encapsulate the interactive data to obtain function call feedback.

[0136] In step S701 of some embodiments, the component communication unit transmits the web page request obtained from the target web page to the registration function component through the second data interaction channel to obtain the target request sent to the registration function component.

[0137] In step S702 of some embodiments, after receiving the target request, the registration function component parses the target request to determine the interactive data requested by the target web page.

[0138] In step S703 of some embodiments, if the registered functional component agrees with the target request, the interactive data needs to be packaged and encapsulated to obtain a function call feedback for responding to the target request.

[0139] In steps S701 to S703 shown in this embodiment, the component communication unit transmits the web page request to the registration function component through the second data interaction channel to obtain the target request. The registration function component then parses the target request to obtain interaction data, and encapsulates the interaction data according to the target request to obtain function call feedback to respond to the function call request sent by the target web page, thereby ensuring the interaction between the target web page and the native function unit.

[0140] In step S603 of some embodiments, the component communication unit transmits the function call feedback to the target web page through the first data interaction channel, thereby realizing the communication interaction between the target web page and the registered function component, and the registered function component is the component registered by the native function unit to the component communication center. Therefore, according to the above-mentioned first data interaction channel, the second data interaction channel and the message listening channel, the communication interaction between the target web page and the native function unit is realized, and the component communication unit can record information for each communication interaction between the target web page and the native function unit to obtain communication interaction information representing the interaction between the target web page and the native function unit.

[0141] In steps S601 to S603 shown in the present embodiment, the component communication unit uses the message monitoring channel to monitor that the target web page sends a function call request to the native function unit, receives the function call request, obtains a web page request from the target web page, and then sends the web page request to the registered function component for response through the second data interaction channel to obtain function call feedback. The component communication unit then transmits the function call feedback to the target web page through the first data interaction channel, and records the function call request and function call feedback this time, to obtain communication interaction information between the target web page and the native function unit, which can realize communication interaction between the target web page and the native function unit based on the component communication unit, thereby reducing the coupling degree between the target web page and the native function unit.

[0142] In an application scenario, when the target web page and the native functional unit are in the same financial product purchasing software, the target web page may be a financial product introduction page in the form of an H5 (fifth edition of Hypertext Markup Language, HTML5) page, and the native functional unit may be a financial product order payment functional unit. In this application scenario, by acquiring the component communication standard between the financial product introduction page and the financial product order payment functional unit, a component communication unit for managing the financial product introduction page and the financial product order payment functional unit, namely, an application scheduling center, is constructed. According to the communication data format of the component communication standard between the financial product introduction page and the financial product order payment functional unit, a communication between the application scheduling center and the financial product introduction page can be constructed. A first data interaction channel between the application scheduling center and a second data interaction channel between the application scheduling center and the financial product order payment function unit. Further, according to the above-mentioned second data interaction channel, the financial product order payment function unit can be registered in the application scheduling center to obtain the registered financial product order payment function component, and through the above-mentioned first data interaction channel, the application scheduling center monitors the financial product introduction page to obtain a message monitoring channel. Finally, when the financial product introduction page initiates an order payment function call to the financial product order payment function unit, the application scheduling center realizes the communication interaction between the financial product introduction page and the financial product order payment function unit through the above-mentioned message monitoring channel, the first data interaction channel and the second data interaction channel.

[0143] The present application constructs a component communication unit between the target web page and the native function unit by acquiring the component communication standard between the target web page and the preset native function unit, so that the data between multiple target web pages and multiple native function units can flow seamlessly, thereby realizing multi-window support. Furthermore, a first data interaction channel between the component communication unit and the target web page, and a second data interaction channel between the component communication unit and the native function unit are constructed, which can improve the immediacy of data transmission between the web page, the native function unit and the component communication unit. Secondly, according to the second data interaction channel, the native function unit is registered with the component communication unit to obtain a registered function component, and according to the first data interaction channel and the component communication unit, the target web page is subscribed to a message to obtain a message listening channel, which reduces the coupling between the web page and the native function in the application, so that each native function unit can be independently developed and maintained. Finally, when the target web page sends a function call request to the native function unit, based on the first data interaction channel, the second data interaction channel and the message listening channel, the target web page and the native function unit are interacted, which can ensure that the target web page and the native function unit can flow seamlessly when decoupled.

[0144] See also Figure 8The embodiment of the present application also provides an interactive device for a web page and a native functional unit, which can implement the interactive method for a web page and a native functional unit, and the device includes:

[0145] The communication standard acquisition module 801 is used to acquire the component communication standard between the target web page and the preset native functional unit;

[0146] The scheduling center construction module 802 is used to construct a component communication unit between the target web page and the native function unit based on the component communication standard;

[0147] An interactive channel construction module 803 is used to construct a first data interactive channel between the component communication unit and the target web page, and a second data interactive channel between the component communication unit and the native function unit;

[0148] The function unit registration module 804 is used to register the native function unit with the component communication unit based on the second data interaction channel to obtain a registered function component;

[0149] A monitoring channel construction module 805 is used to subscribe to a message on a target web page based on the first data interaction channel and the component communication unit to obtain a message monitoring channel;

[0150] The data communication interaction module 806 is used to interact the target web page and the native functional unit based on the first data interaction channel, the second data interaction channel and the message monitoring channel when the target web page sends a function call request to the native functional unit.

[0151] The specific implementation of the device for interacting between a web page and a native functional unit is substantially the same as the specific implementation of the method for interacting between a web page and a native functional unit described above, and will not be described in detail herein.

[0152] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned method of interacting with the web page and the native functional unit when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0153] See also Fig. 9 , Fig. 9 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0154] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0155] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the method for interacting between the web page and the native functional unit in the embodiment of the present application;

[0156] Input / output interface 903, used to implement information input and output;

[0157] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);

[0158] A bus 905 that transmits information between the various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);

[0159] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .

[0160] The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned method of interaction between the web page and the native functional unit.

[0161] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0162] The embodiments of the present application provide a method for interacting with a web page and a native function unit, an apparatus for interacting with a web page and a native function unit, an electronic device, and a storage medium. The method acquires a component communication standard between a target web page and a preset native function unit to construct a component communication unit between the target web page and the native function unit, and then constructs a first data interaction channel between the component communication unit and the target web page, and a second data interaction channel between the component communication unit and the native function unit. Secondly, according to the second data interaction channel, the native function unit is registered with the component communication unit to obtain a registered function component. According to the first data interaction channel and the component communication unit, the target web page is subscribed to a message to obtain a message listening channel. Finally, when the target web page sends a function call request to the native function unit, the target web page and the native function unit are interacted with based on the first data interaction channel, the second data interaction channel, and the message listening channel.

[0163] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0164] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0165] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0166] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0167] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application 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 interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0168] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0169] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0170] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0171] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0172] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0173] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A method for interaction between a web page and a native functional unit, characterized in that: The method comprises: Acquire a component communication standard between a target web page and a preset native functional unit; Based on the component communication standard, construct a component communication unit between the target web page and the native function unit; Establishing a first data interaction channel between the component communication unit and the target web page, and a second data interaction channel between the component communication unit and the native function unit; Based on the second data interaction channel, registering the native function unit to the component communication unit to obtain a registered function component; Based on the first data interaction channel and the component communication unit, subscribe to the target web page for messages to obtain a message monitoring channel; When the target web page sends a function call request to the native function unit, the target web page and the native function unit interact based on the first data interaction channel, the second data interaction channel and the message monitoring channel.

2. The method according to claim 1, characterized in that: The component communication standard includes a communication event name and a communication data format. The component communication unit between the target web page and the native function unit is constructed based on the component communication standard, including: Determining a communication unit management event between the target web page and the native functional unit based on the communication event name; Building an event management component based on the communication unit management event; Based on the communication data format, construct a data transmission interface; The event management component and the data transmission interface are component-merged to obtain the component communication unit.

3. The method according to claim 1, characterized in that When the target webpage sends a function call request to the native function unit, the target webpage and the native function unit are interacted based on the first data interaction channel, the second data interaction channel and the message monitoring channel, including: When the target web page sends a function call request to the native function unit, based on the message monitoring channel, information of the function call request is received to obtain a web page request; Based on the second data interaction channel and the registration function component, respond to the webpage request to obtain function call feedback; Based on the first data interaction channel and the function call feedback, a feedback request is made to the target web page to obtain communication interaction information between the target web page and the native function unit.

4. The method according to claim 3, characterized in that The step of responding to the webpage request based on the second data interaction channel and the registration function component to obtain function call feedback includes: Based on the second data interaction channel and the component communication unit, the web page request is transmitted to the registration function component to obtain a target request; Based on the registration function component, the target request is parsed to obtain interaction data; Based on the target request, the interactive data is data encapsulated to obtain the function call feedback.

5. The method according to claim 1, characterized in that The registering the native function unit to the component communication unit based on the second data interaction channel to obtain a registered function component includes: Defining a registration interface for the component communication unit to obtain a functional component registration interface; Based on the native functional unit, a registration method is defined for the component communication unit to obtain a functional component registration method; Based on the functional component registration method and the component communication unit, construct a component registration request; Based on the native functional unit and the second data interaction channel, the component registration request is sent to the functional component registration interface of the component communication unit to obtain the registered functional component.

6. The method according to claim 5, characterized in that The native function unit includes a function name, a function description and a function event type. The registration method of the component communication unit is defined based on the native function unit and the second data interaction channel to obtain a function component registration method, including: Based on the function name, label the native function unit to obtain a function identifier; Determining function information of the native function unit based on the function description and the function event type; The function identifier and the function information are merged to obtain the function component registration method.

7. The method according to any one of claims 1 to 6, characterized in that: The method of subscribing to a message of the target web page based on the first data interaction channel and the component communication unit to obtain a message monitoring channel includes: Based on the component communication unit and the first data interaction channel, sending a message subscription request to the target web page; Based on the target web page, respond to the message subscription request to obtain message subscription feedback data; Creating a page message listener for the target web page based on the first data interaction channel and the message subscription response; The page message listener is registered in the component communication unit to obtain the message monitoring channel.

8. An interactive device for a web page and a native functional unit, characterized in that: The device comprises: A communication standard acquisition module, used to acquire the component communication standard between the target web page and the preset native functional unit; A dispatch center construction module, used to construct a component communication unit between the target web page and the native function unit based on the component communication standard; An interactive channel construction module, used to construct a first data interactive channel between the component communication unit and the target web page, and a second data interactive channel between the component communication unit and the native function unit; A function unit registration module, used to register the native function unit with the component communication unit based on the second data interaction channel to obtain a registered function component; A monitoring channel construction module, used to subscribe to a message of the target web page based on the first data interaction channel and the component communication unit to obtain a message monitoring channel; The page function interaction module is used to interact the target web page and the native function unit based on the first data interaction channel, the second data interaction channel and the message monitoring channel when the target web page sends a function call request to the native function unit.

9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the method for interacting between a web page and a native functional unit as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for interacting between a web page and a native functional unit according to any one of claims 1 to 7 is implemented.