H5 interaction methods, devices, equipment, and storage media with applications
By generating asynchronous callback functions applicable to different system types, the problem of inconvenient maintenance of callback functions in the interaction between H5 and native APP is solved, improving development efficiency and code readability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN PING AN SMART HEALTHCARE TECH CO LTD
- Filing Date
- 2022-03-10
- Publication Date
- 2026-07-03
Smart Images

Figure CN114610386B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of process optimization technology, and in particular to an interaction method, apparatus, device, and storage medium for H5 and applications. Background Technology
[0002] Currently, in the interaction solutions between H5 and native apps, the devices on which the native app is located may have different system types, which requires maintaining two sets of callback functions. In addition, when dealing with different business scenarios, it is necessary to use identifier parameters to distinguish callback functions, which is not conducive to the interaction between H5 and native apps. Summary of the Invention
[0003] In view of the above, it is necessary to provide an interaction method, device, equipment and storage medium between H5 and application, which can not only generate callback functions applicable to different system types, but also eliminate the need to identify callback functions to distinguish different business scenarios, which is beneficial to the interaction between H5 and native APP.
[0004] On one hand, this invention proposes a method for interaction between H5 and an application, the method comprising:
[0005] Obtain the call request initiated by H5 to the target application;
[0006] The request type of the call request is detected based on a preset interaction list;
[0007] If the request type is asynchronous, a callback function is generated based on the call request;
[0008] Generate a page request based on the call request and the function name of the callback function;
[0009] The system type of the target application is identified based on the call request;
[0010] The page request is processed according to the system type to obtain request forwarding information;
[0011] The request relay information is parsed based on the callback function to obtain the request result.
[0012] According to a preferred embodiment of the present invention, the step of detecting the request type of the call request based on a preset interaction list includes:
[0013] Extract the program method name of the target application from the call request;
[0014] Traverse the preset interaction list based on the program method name;
[0015] If the preset interaction list contains a callback method name corresponding to the program method name, then the request type is determined to be the asynchronous type.
[0016] According to a preferred embodiment of the present invention, generating a callback function based on the call request includes:
[0017] Extract parameter information from the call request;
[0018] The parameter information is processed using a random function generator to obtain the function name and function information;
[0019] Retrieve the function method corresponding to the function name;
[0020] Write the function information into the function method to obtain the code information;
[0021] Run the code to generate the callback function.
[0022] According to a preferred embodiment of the present invention, identifying the system type of the target application based on the call request includes:
[0023] Extract address information from the call request;
[0024] Extract the information corresponding to the preset tag from the address information to generate the address;
[0025] The device corresponding to the generated address is designated as the program device where the target application resides.
[0026] Obtain the device code from the program device;
[0027] The system type is obtained by identifying the device code using a user agent detection tool.
[0028] According to a preferred embodiment of the present invention, processing the page request according to the system type to obtain request relay information includes:
[0029] Select the parameter processor corresponding to the system type;
[0030] Count the number of names of the function;
[0031] The page request is segmented based on the number of names to obtain multiple sub-requests;
[0032] The parameter processor is invoked to process the multiple sub-requests in parallel, and response information corresponding to each sub-request is obtained;
[0033] Detect the request position of each sub-request within the page request;
[0034] The request relay information is obtained by concatenating the response information based on the requested location.
[0035] According to a preferred embodiment of the present invention, when the parameter processor is invoked to process the multiple sub-requests in parallel, the interaction method between the H5 and the application further includes:
[0036] The parameter processor monitors the multiple sub-requests in parallel and obtains the monitoring results.
[0037] Extract the sub-requests from the plurality of sub-requests whose monitoring results are abnormal as target requests, and extract the location of the target request from the request location as target location;
[0038] Generate feedback information based on the target request and the target location;
[0039] The feedback information is sent to the preset bound terminal.
[0040] According to a preferred embodiment of the present invention, after parsing the request relay information based on the callback function to obtain the request result, the interaction method between the H5 and the application further includes:
[0041] Calculate the information similarity between the request result and the configuration information;
[0042] If the information similarity is less than a preset threshold, then the callback function is deleted.
[0043] On the other hand, the present invention also proposes an interaction device between H5 and an application, the interaction device between H5 and the application comprising:
[0044] The acquisition unit is used to acquire the call request initiated by H5 to the target application;
[0045] The detection unit is used to detect the request type of the call request based on a preset interaction list;
[0046] A generation unit is configured to generate a callback function based on the call request if the request type is asynchronous.
[0047] The generation unit is further configured to generate a page request based on the call request and the function name of the callback function;
[0048] The identification unit is used to identify the system type of the target application based on the call request;
[0049] The processing unit is used to process the page request according to the system type and obtain request relay information;
[0050] The parsing unit is used to parse the request relay information based on the callback function to obtain the request result.
[0051] On the other hand, the present invention also proposes an electronic device, the electronic device comprising:
[0052] Memory, which stores computer-readable instructions; and
[0053] The processor executes computer-readable instructions stored in the memory to implement the H5 interaction method with the application.
[0054] On the other hand, the present invention also proposes a computer-readable storage medium storing computer-readable instructions, which are executed by a processor in an electronic device to implement the interaction method between the H5 and the application.
[0055] As can be seen from the above technical solutions, the present invention directly generates a callback function based on the call request. Since there is no need to use different naming methods to generate the callback function based on different system types, it can generate callback functions applicable to different system types, thereby improving the maintenance convenience of the callback function. In addition, the callback function is randomly generated based on the call request when the request type is detected to be asynchronous. Therefore, when the application's business scenario changes, there is no need to identify the callback function to distinguish different business scenarios, improving development efficiency. Furthermore, generating a page request based on the call request and the function name can avoid the separation of asynchronous call requests and callback functions, improving code readability and maintainability. Since the call request is converted into the page request, it can not only avoid the call request and the callback function being stored in the same path, causing excessive coupling of business logic between the call request and the callback function, but also avoid the storage dispersion caused by the call request and the callback function being stored in different paths. Attached Figure Description
[0056] Figure 1 This is a flowchart of a preferred embodiment of the interaction method between H5 and application of the present invention.
[0057] Figure 2 This is a functional block diagram of a preferred embodiment of the interaction device between H5 and application of the present invention.
[0058] Figure 3 This is a schematic diagram of the structure of an electronic device that is a preferred embodiment of the interaction method between H5 and applications according to the present invention. Detailed Implementation
[0059] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0060] like Figure 1 The diagram shown is a flowchart of a preferred embodiment of the interaction method between H5 and the application of the present invention. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.
[0061] The interaction method between the H5 and the application can be based on artificial intelligence technology to acquire and process relevant data. 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 that knowledge to obtain optimal results.
[0062] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0063] The H5 interaction method is applied to one or more electronic devices. The electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored computer-readable instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0064] The electronic device can be any electronic product that can interact with the user, such as a personal computer, tablet computer, smartphone, personal digital assistant (PDA), game console, interactive network television (IPTV), smart wearable device, etc.
[0065] The electronic devices may include network devices and / or user devices. The network devices include, but are not limited to, single network electronic devices, groups of multiple network electronic devices, or cloud computing-based systems consisting of a large number of hosts or network electronic devices.
[0066] The network in which the electronic device is located includes, but is not limited to: the Internet, wide area network, metropolitan area network, local area network, virtual private network (VPN), etc.
[0067] S10, obtain the call request initiated by H5 to the target application.
[0068] In at least one embodiment of the present invention, the target application can be any application related to a business scenario, for example, the target application can be a payment application.
[0069] The information carried in the call request includes, but is not limited to, the program method name, parameter information, and address information of the target application. The parameter information refers to the parameters contained in the object within the call request. The address information includes the address that generated the call request and the address that processed the call request.
[0070] In at least one embodiment of the present invention, the electronic device invokes a monitoring tool to monitor the H5 page, and when it detects that relevant information related to the target application is generated on the H5 page, the electronic device obtains the invocation request.
[0071] S11, Detect the request type of the call request based on the preset interaction list.
[0072] In at least one embodiment of the present invention, the preset interaction list stores a mapping relationship between program method names and calling method names in asynchronous types.
[0073] The request types include asynchronous and synchronous types.
[0074] In at least one embodiment of the present invention, the electronic device detects the request type of the call request based on a preset interaction list, including:
[0075] Extract the program method name of the target application from the call request;
[0076] Traverse the preset interaction list based on the program method name;
[0077] If the preset interaction list contains a callback method name corresponding to the program method name, then the request type is determined to be the asynchronous type.
[0078] The program method name is used to indicate the target application.
[0079] The program method name can be accurately extracted through the call request, and then the preset interaction list can be detected based on the program method name, which improves the accuracy of the request type determination.
[0080] In at least one embodiment of the present invention, if there is no callback method name corresponding to the program method name in the preset interaction list, the request type is determined to be a synchronous type.
[0081] In at least one embodiment of the present invention, after detecting the request type of the call request based on a preset interaction list, the interaction method between the H5 and the application further includes:
[0082] If the request type is synchronous, then the call request is executed, and the request result is obtained.
[0083] Through the above implementation method, when the request type is synchronous, the call request can be run directly, thereby improving the efficiency of generating the request result.
[0084] S12, if the request type is asynchronous, generate a callback function based on the call request.
[0085] In at least one embodiment of the present invention, the callback function refers to a function used to pass parameter information in the call request.
[0086] In at least one embodiment of the present invention, the electronic device generating a callback function based on the call request includes:
[0087] Extract parameter information from the call request;
[0088] The parameter information is processed using a random function generator to obtain the function name and function information;
[0089] Retrieve the function method corresponding to the function name;
[0090] Write the function information into the function method to obtain the code information;
[0091] Run the code to generate the callback function.
[0092] The parameter information refers to the parameters contained in the object in the call request.
[0093] By processing the parameter information using the random function generator, a function name and function information suitable for the call request can be generated, thereby improving the accuracy of the callback function generation.
[0094] S13, Generate a page request based on the call request and the function name of the callback function.
[0095] In at least one embodiment of the present invention, the page request refers to a request that the electronic device can directly run.
[0096] In at least one embodiment of the present invention, the electronic device generating a page request based on the invocation request and the function name of the callback function includes:
[0097] The function name is written into the call request to obtain the page request.
[0098] S14, Identify the system type of the target application based on the call request.
[0099] In at least one embodiment of the present invention, the system type refers to the code type corresponding to the code in the target application. For example, the system type may be JAVA, etc.
[0100] In at least one embodiment of the present invention, the electronic device identifies the system type of the target application based on the invocation request, including:
[0101] Extract address information from the call request;
[0102] Extract the information corresponding to the preset tag from the address information to generate the address;
[0103] The device corresponding to the generated address is designated as the program device where the target application resides.
[0104] Obtain the device code from the program device;
[0105] The system type is obtained by identifying the device code using a user agent detection tool.
[0106] The address information includes the address that generated the call request and the address that processed the call request.
[0107] The preset label is the address where the user-indicated information is generated; for example, the preset label could be "from".
[0108] The program device is the same as the device that generated the call request.
[0109] The device code can be any code information on the operating system platform of the program device.
[0110] The user agent detection tool usually refers to the UserAgent tool.
[0111] The program device can be accurately located through the call request and the preset tag, and the system type can be accurately determined based on the identification of the device code by the user agent detection tool.
[0112] S15, process the page request according to the system type to obtain request relay information.
[0113] In at least one embodiment of the present invention, the request relay information refers to the response result corresponding to the page request.
[0114] In at least one embodiment of the present invention, the electronic device processes the page request according to the system type and obtains request relay information including:
[0115] Select the parameter processor corresponding to the system type;
[0116] Count the number of names of the function;
[0117] The page request is segmented based on the number of names to obtain multiple sub-requests;
[0118] The parameter processor is invoked to process the multiple sub-requests in parallel, and response information corresponding to each sub-request is obtained;
[0119] Detect the request position of each sub-request within the page request;
[0120] The request relay information is obtained by concatenating the response information based on the requested location.
[0121] The parameter processor can refer to an Android parameter processor, or an iOS parameter processor, etc.
[0122] By segmenting the page request according to the number of names, sub-requests corresponding to each parameter information can be generated. Then, the parameter processor can be invoked to process the multiple sub-requests in parallel, improving the efficiency of response information generation. Furthermore, by concatenating the response information according to the request position, the accuracy of the request relay information can be improved.
[0123] In at least one embodiment of the present invention, when the parameter processor is invoked to process the plurality of sub-requests in parallel, the interaction method between the H5 and the application further includes:
[0124] The parameter processor monitors the multiple sub-requests in parallel and obtains the monitoring results.
[0125] Extract the sub-requests from the plurality of sub-requests whose monitoring results are abnormal as target requests, and extract the location of the target request from the request location as target location;
[0126] Generate feedback information based on the target request and the target location;
[0127] The feedback information is sent to the preset bound terminal.
[0128] The abnormal monitoring results include situations such as: the parameter processor being unable to process the sub-request, or the parameter processor taking longer than a preset time to process the sub-request.
[0129] The preset bound terminal can be a terminal device bound by the operation and maintenance user responsible for the target application.
[0130] Through the above implementation method, it is possible to capture anomalies when the parameter processor processes the multiple sub-requests in parallel, and then generate the feedback information, which is beneficial to notify the operation and maintenance personnel in a timely manner when an anomaly is captured.
[0131] S16, based on the callback function, parse the request relay information to obtain the request result.
[0132] It should be emphasized that, to further ensure the privacy and security of the above request results, the above request results can also be stored in a node of a blockchain.
[0133] In at least one embodiment of the present invention, after parsing the request relay information based on the callback function and obtaining the request result, the interaction method between the H5 and the application further includes:
[0134] Calculate the information similarity between the request result and the configuration information;
[0135] If the information similarity is less than a preset threshold, then the callback function is deleted.
[0136] The configuration information refers to the preset information when the request fails to execute; for example, the configuration information may be "unresponsive".
[0137] The preset threshold can be set according to actual needs, and the present invention does not impose specific limitations on the value of the preset threshold.
[0138] Through the above implementation method, when the information similarity is less than the preset threshold, it indicates that the call request has been successfully executed. Therefore, destroying the callback function when the call request is successfully executed can avoid the dimension of the callback function and improve convenience.
[0139] As can be seen from the above technical solutions, the present invention directly generates a callback function based on the call request. Since there is no need to use different naming methods to generate the callback function based on different system types, it can generate callback functions applicable to different system types, thereby improving the maintenance convenience of the callback function. In addition, the callback function is randomly generated based on the call request when the request type is detected to be asynchronous. Therefore, when the application's business scenario changes, there is no need to identify the callback function to distinguish different business scenarios, improving development efficiency. Furthermore, generating a page request based on the call request and the function name can avoid the separation of asynchronous call requests and callback functions, improving code readability and maintainability. Since the call request is converted into the page request, it can not only avoid the call request and the callback function being stored in the same path, causing excessive coupling of business logic between the call request and the callback function, but also avoid storage dispersion caused by the call request and the callback function being stored in different paths.
[0140] like Figure 2 The diagram shown is a functional block diagram of a preferred embodiment of the H5 and application interaction device of the present invention. The H5 and application interaction device 11 includes an acquisition unit 110, a detection unit 111, a generation unit 112, an identification unit 113, a processing unit 114, a parsing unit 115, a monitoring unit 116, an extraction unit 117, a sending unit 118, a calculation unit 119, and a deletion unit 120. The module / unit referred to in this invention refers to a series of computer-readable instruction segments that can be acquired by the processor 13 and perform a fixed function, stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0141] Unit 110 acquires the call request initiated by H5 to the target application.
[0142] In at least one embodiment of the present invention, the target application can be any application related to a business scenario, for example, the target application can be a payment application.
[0143] The information carried in the call request includes, but is not limited to, the program method name, parameter information, and address information of the target application. The parameter information refers to the parameters contained in the object within the call request. The address information includes the address that generated the call request and the address that processed the call request.
[0144] In at least one embodiment of the present invention, the acquisition unit 110 calls a monitoring tool to monitor H5, and when it detects that relevant information related to the target application is generated on H5, the acquisition unit 110 acquires the call request.
[0145] The detection unit 111 detects the request type of the call request based on a preset interaction list.
[0146] In at least one embodiment of the present invention, the preset interaction list stores a mapping relationship between program method names and calling method names in asynchronous types.
[0147] The request types include asynchronous and synchronous types.
[0148] In at least one embodiment of the present invention, the detection unit 111 detects the request type of the call request based on a preset interaction list, including:
[0149] Extract the program method name of the target application from the call request;
[0150] Traverse the preset interaction list based on the program method name;
[0151] If the preset interaction list contains a callback method name corresponding to the program method name, then the request type is determined to be the asynchronous type.
[0152] The program method name is used to indicate the target application.
[0153] The program method name can be accurately extracted through the call request, and then the preset interaction list can be detected based on the program method name, which improves the accuracy of the request type determination.
[0154] In at least one embodiment of the present invention, if there is no callback method name corresponding to the program method name in the preset interaction list, the detection unit 111 determines the request type as a synchronous type.
[0155] In at least one embodiment of the present invention, after detecting the request type of the call request based on a preset interaction list, if the request type is a synchronous type, the processing unit 114 runs the call request and obtains the request result.
[0156] Through the above implementation method, when the request type is synchronous, the call request can be run directly, thereby improving the efficiency of generating the request result.
[0157] If the request type is asynchronous, the generation unit 112 generates a callback function based on the call request.
[0158] In at least one embodiment of the present invention, the callback function refers to a function used to pass parameter information in the call request.
[0159] In at least one embodiment of the present invention, the generation unit 112 generates a callback function based on the call request, including:
[0160] Extract parameter information from the call request;
[0161] The parameter information is processed using a random function generator to obtain the function name and function information;
[0162] Retrieve the function method corresponding to the function name;
[0163] Write the function information into the function method to obtain the code information;
[0164] Run the code to generate the callback function.
[0165] The parameter information refers to the parameters contained in the object in the call request.
[0166] By processing the parameter information using the random function generator, a function name and function information suitable for the call request can be generated, thereby improving the accuracy of the callback function generation.
[0167] The generation unit 112 generates a page request based on the call request and the function name of the callback function.
[0168] In at least one embodiment of the present invention, the page request refers to a request that the electronic device can directly run.
[0169] In at least one embodiment of the present invention, the generation unit 112 generates a page request based on the call request and the function name of the callback function, including:
[0170] The function name is written into the call request to obtain the page request.
[0171] The identification unit 113 identifies the system type of the target application based on the call request.
[0172] In at least one embodiment of the present invention, the system type refers to the code type corresponding to the code in the target application. For example, the system type may be JAVA, etc.
[0173] In at least one embodiment of the present invention, the identification unit 113 identifies the system type of the target application based on the call request, including:
[0174] Extract address information from the call request;
[0175] Extract the information corresponding to the preset tag from the address information to generate the address;
[0176] The device corresponding to the generated address is designated as the program device where the target application resides.
[0177] Obtain the device code from the program device;
[0178] The system type is obtained by identifying the device code using a user agent detection tool.
[0179] The address information includes the address that generated the call request and the address that processed the call request.
[0180] The preset label is the address where the user-indicated information is generated; for example, the preset label could be "from".
[0181] The program device is the same as the device that generated the call request.
[0182] The device code can be any code information on the operating system platform of the program device.
[0183] The user agent detection tool usually refers to the UserAgent tool.
[0184] The program device can be accurately located through the call request and the preset tag, and the system type can be accurately determined based on the identification of the device code by the user agent detection tool.
[0185] The processing unit 114 processes the page request according to the system type to obtain request forwarding information.
[0186] In at least one embodiment of the present invention, the request relay information refers to the response result corresponding to the page request.
[0187] In at least one embodiment of the present invention, the processing unit 114 processes the page request according to the system type and obtains request relay information including:
[0188] Select the parameter processor corresponding to the system type;
[0189] Count the number of names of the function;
[0190] The page request is segmented based on the number of names to obtain multiple sub-requests;
[0191] The parameter processor is invoked to process the multiple sub-requests in parallel, and response information corresponding to each sub-request is obtained;
[0192] Detect the request position of each sub-request within the page request;
[0193] The request relay information is obtained by concatenating the response information based on the requested location.
[0194] The parameter processor can refer to an Android parameter processor, or an iOS parameter processor, etc.
[0195] By segmenting the page request according to the number of names, sub-requests corresponding to each parameter information can be generated. Then, the parameter processor can be invoked to process the multiple sub-requests in parallel, improving the efficiency of response information generation. Furthermore, by concatenating the response information according to the request position, the accuracy of the request relay information can be improved.
[0196] In at least one embodiment of the present invention, when the parameter processor is invoked to process the plurality of sub-requests in parallel, the monitoring unit 116 monitors the parameter processor to process the plurality of sub-requests in parallel and obtains the monitoring result.
[0197] Extraction unit 117 extracts the sub-requests whose monitoring results are abnormal from the plurality of sub-requests as target requests, and extracts the location of the target request from the request location as target location;
[0198] The generation unit 112 generates feedback information based on the target request and the target location;
[0199] The sending unit 118 sends the feedback information to the preset bound terminal.
[0200] The abnormal monitoring results include situations such as: the parameter processor being unable to process the sub-request, or the parameter processor taking longer than a preset time to process the sub-request.
[0201] The preset bound terminal can be a terminal device bound by the operation and maintenance user responsible for the target application.
[0202] Through the above implementation method, it is possible to capture anomalies when the parameter processor processes the multiple sub-requests in parallel, and then generate the feedback information, which is beneficial to notify the operation and maintenance personnel in a timely manner when an anomaly is captured.
[0203] The parsing unit 115 parses the request relay information based on the callback function to obtain the request result.
[0204] It should be emphasized that, to further ensure the privacy and security of the above request results, the above request results can also be stored in a node of a blockchain.
[0205] In at least one embodiment of the present invention, after parsing the request relay information based on the callback function and obtaining the request result, the calculation unit 119 calculates the information similarity between the request result and the configuration information;
[0206] If the information similarity is less than a preset threshold, the deletion unit 120 deletes the callback function.
[0207] The configuration information refers to the preset information when the request fails to execute; for example, the configuration information may be "unresponsive".
[0208] The preset threshold can be set according to actual needs, and the present invention does not impose specific limitations on the value of the preset threshold.
[0209] Through the above implementation method, when the information similarity is less than the preset threshold, it indicates that the call request has been successfully executed. Therefore, destroying the callback function when the call request is successfully executed can avoid the dimension of the callback function and improve convenience.
[0210] As can be seen from the above technical solutions, the present invention directly generates a callback function based on the call request. Since there is no need to use different naming methods to generate the callback function based on different system types, it can generate callback functions applicable to different system types, thereby improving the maintenance convenience of the callback function. In addition, the callback function is randomly generated based on the call request when the request type is detected to be asynchronous. Therefore, when the application's business scenario changes, there is no need to identify the callback function to distinguish different business scenarios, improving development efficiency. Furthermore, generating a page request based on the call request and the function name can avoid the separation of asynchronous call requests and callback functions, improving code readability and maintainability. Since the call request is converted into the page request, it can not only avoid the call request and the callback function being stored in the same path, causing excessive coupling of business logic between the call request and the callback function, but also avoid storage dispersion caused by the call request and the callback function being stored in different paths.
[0211] like Figure 3 The diagram shown is a schematic representation of the structure of an electronic device that implements the interaction method between H5 and applications according to the present invention.
[0212] In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and computer-readable instructions stored in the memory 12 and executable on the processor 13, such as H5 interactive programs for applications.
[0213] Those skilled in the art will understand that the schematic diagram is merely an example of electronic device 1 and does not constitute a limitation on electronic device 1. It may include more or fewer components than shown in the diagram, or combine certain components, or different components. For example, electronic device 1 may also include input / output devices, network access devices, buses, etc.
[0214] The processor 13 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. The processor 13 is the computing core and control center of the electronic device 1, connecting various parts of the electronic device 1 through various interfaces and lines, and executing the operating system of the electronic device 1, as well as various installed application programs and program code.
[0215] For example, the computer-readable instructions can be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present invention. The one or more modules / units can be a series of computer-readable instruction segments capable of performing specific functions, which describe the execution process of the computer-readable instructions in the electronic device 1. For example, the computer-readable instructions can be divided into an acquisition unit 110, a detection unit 111, a generation unit 112, an identification unit 113, a processing unit 114, a parsing unit 115, a monitoring unit 116, an extraction unit 117, a sending unit 118, a calculation unit 119, and a deletion unit 120.
[0216] The memory 12 can be used to store the computer-readable instructions and / or modules. The processor 13 implements various functions of the electronic device 1 by running or executing the computer-readable instructions and / or modules stored in the memory 12 and calling the data stored in the memory 12. The memory 12 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. The memory 12 may include non-volatile and volatile memory, such as: hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other storage devices.
[0217] The memory 12 can be the external memory and / or internal memory of the electronic device 1. Furthermore, the memory 12 can be a physical memory, such as a memory module, a TF card (Trans-flash Card), etc.
[0218] If the modules / units integrated in the electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by instructing related hardware through computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium, and when executed by a processor, the computer-readable instructions can implement the steps of the various method embodiments described above.
[0219] The computer-readable instructions include computer-readable instruction code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer-readable instruction code, recording medium, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), and random access memory (RAM).
[0220] The blockchain referred to in this invention is a novel application model of computer technologies such as distributed H5 and application interaction, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.
[0221] Combination Figure 1 The memory 12 in the electronic device 1 stores computer-readable instructions to implement an H5 interaction method with an application, and the processor 13 can execute the computer-readable instructions to achieve the following:
[0222] Obtain the call request initiated by H5 to the target application;
[0223] The request type of the call request is detected based on a preset interaction list;
[0224] If the request type is asynchronous, a callback function is generated based on the call request;
[0225] Generate a page request based on the call request and the function name of the callback function;
[0226] The system type of the target application is identified based on the call request;
[0227] The page request is processed according to the system type to obtain request forwarding information;
[0228] The request relay information is parsed based on the callback function to obtain the request result.
[0229] Specifically, the specific implementation method of the processor 13 for the above-mentioned computer-readable instructions can be found in [reference needed]. Figure 1 The descriptions of the relevant steps in the corresponding embodiments are not repeated here.
[0230] In the several embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0231] The computer-readable storage medium stores computer-readable instructions, which, when executed by the processor 13, are used to perform the following steps:
[0232] Obtain the call request initiated by H5 to the target application;
[0233] The request type of the call request is detected based on a preset interaction list;
[0234] If the request type is asynchronous, a callback function is generated based on the call request;
[0235] Generate a page request based on the call request and the function name of the callback function;
[0236] The system type of the target application is identified based on the call request;
[0237] The page request is processed according to the system type to obtain request forwarding information;
[0238] The request relay information is parsed based on the callback function to obtain the request result.
[0239] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0240] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0241] Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within the invention. No appended diagram markings in the claims should be construed as limiting the scope of the claims.
[0242] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The multiple units or devices described may also be implemented by a single unit or device through software or hardware. Terms such as "first," "second," etc., are used to indicate names and do not indicate any specific order.
[0243] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for interaction between H5 and an application, characterized in that, The interaction methods between the H5 and the application include: Obtain the call request initiated by H5 to the target application; The request type of the call request is detected based on a preset interaction list; If the request type is asynchronous, generating a callback function based on the call request includes: extracting parameter information from the call request, where the parameter information refers to the parameters contained in the object in the call request; processing the parameter information based on a random function generator to obtain a function name and function information; obtaining a function method corresponding to the function name; writing the function information into the function method to obtain code information; and running the code information to generate the callback function, which is used to pass the parameter information in the call request. Write the function name of the callback function into the call request to generate a page request; The system type of the target application is identified based on the call request; The page request is processed according to the system type to obtain request relay information, including: selecting a parameter processor corresponding to the system type; counting the number of function names; segmenting the page request based on the number of names to obtain multiple sub-requests; calling the parameter processor to process the multiple sub-requests in parallel to obtain response information corresponding to each sub-request; detecting the request position of each sub-request in the page request; and concatenating the response information based on the request position to obtain the request relay information. The request relay information is parsed based on the callback function to obtain the request result.
2. The H5 and application interaction method as described in claim 1, characterized in that, The request type detected based on the preset interaction list includes: Extract the program method name of the target application from the call request; Traverse the preset interaction list based on the program method name; If the preset interaction list contains a callback method name corresponding to the program method name, then the request type is determined to be the asynchronous type.
3. The H5 interaction method with the application as described in claim 1, characterized in that, The process of identifying the system type of the target application based on the call request includes: Extract address information from the call request; Extract the information corresponding to the preset tag from the address information to generate the address; The device corresponding to the generated address is designated as the program device where the target application resides. Obtain the device code from the program device; The system type is obtained by identifying the device code using a user agent detection tool.
4. The H5 interaction method with the application as described in claim 1, characterized in that, When the parameter processor is invoked to process the multiple sub-requests in parallel, the interaction method between the H5 and the application further includes: The parameter processor monitors the multiple sub-requests in parallel and obtains the monitoring results. Extract the sub-requests from the plurality of sub-requests whose monitoring results are abnormal as target requests, and extract the location of the target request from the request location as target location; Generate feedback information based on the target request and the target location; The feedback information is sent to the preset bound terminal.
5. The H5 interaction method with the application as described in claim 1, characterized in that, After parsing the request relay information based on the callback function and obtaining the request result, the interaction method between the H5 and the application further includes: Calculate the information similarity between the request result and the configuration information; If the information similarity is less than a preset threshold, then the callback function is deleted.
6. An interactive device for H5 and applications, characterized in that, The device is used to implement the H5 and application interaction method as described in any one of claims 1 to 5, wherein the H5 and application interaction device includes: The acquisition unit is used to acquire the call request initiated by H5 to the target application; The detection unit is used to detect the request type of the call request based on a preset interaction list; A generation unit, configured to generate a callback function based on the call request if the request type is asynchronous, includes: extracting parameter information from the call request, wherein the parameter information refers to the parameters contained in the object in the call request; processing the parameter information based on a random function generator to obtain the function name and function information; obtaining the function method corresponding to the function name; writing the function information into the function method to obtain code information; and running the code information to generate the callback function. The generation unit is further configured to generate a page request based on the call request and the function name of the callback function; The identification unit is used to identify the system type of the target application based on the call request; The processing unit is configured to process the page request according to the system type to obtain request relay information, including: selecting a parameter processor corresponding to the system type; counting the number of function names; segmenting the page request based on the number of names to obtain multiple sub-requests; calling the parameter processor to process the multiple sub-requests in parallel to obtain response information corresponding to each sub-request; detecting the request position of each sub-request in the page request; and concatenating the response information based on the request position to obtain the request relay information. The parsing unit is used to parse the request relay information based on the callback function to obtain the request result.
7. An electronic device, characterized in that, The electronic device includes: Memory, which stores computer-readable instructions; and The processor executes computer-readable instructions stored in the memory to implement the H5 interaction method with the application as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which are executed by a processor in an electronic device to implement the H5 and application interaction method as described in any one of claims 1 to 5.