Web end and Native end interaction method and device based on communication bridge, equipment and medium

By building a target communication bridge between the web and the Native side, the compatibility, security and performance problems of JSBridge during interaction are solved, and efficient, secure and instant interaction effects are achieved.

CN119690697APending Publication Date: 2025-03-25CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411552109.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

Existing JSBridge has compatibility, security and performance issues when interacting between the Web and Native, resulting in inefficiency in interaction.

Method used

By building a target communication bridge between the Native end and the Web end, listening to the function call request initiated by the Web end, generating interface call data, and sending data to the Native end through the target communication bridge, executing corresponding tasks and returning results.

Benefits of technology

It eliminates the complexity and delay of communication between the web and the Native side, improves interaction efficiency, ensures the accuracy of requests and the immediacy of responses, and enhances the security and performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690697A_ABST
    Figure CN119690697A_ABST
Patent Text Reader

Abstract

The invention provides a Web end and Native end interaction method and device based on a communication bridge, equipment and a medium, and relates to the technical field of computers. According to the method provided by the invention, the target communication bridge between the Native end and the Web end is constructed, so that the Web end can directly perform data exchange and function calling with the Native end, the complexity and delay of communication between the Web end and the Native end are eliminated, and the interaction efficiency between the Web and the Native is improved. The target communication bridge is utilized to send the interface calling data to the Native end, the Native end is allowed to directly execute the corresponding interface method, the request of the Web end can be quickly responded, and the task execution speed and efficiency are improved. And the task execution result is sent back to the Web end through the target communication bridge, so that the instantaneity of response is ensured, the accuracy and integrity of data are ensured, and the interaction reliability between the Web and the Native is improved. By simplifying the communication process, the data processing efficiency is improved, the data transmission accuracy is ensured, and the interaction efficiency between the Web and the Native is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and medium for interaction between a Web terminal and a Native terminal based on a communication bridge. Background Art

[0002] JSBridge is a technology for communication between JavaScript and Native code, which is widely used in mobile application development. Although JSBridge has great advantages in cross-platform development and function expansion, it also has some shortcomings and problems:

[0003] 1. Compatibility issues: Different mobile platforms and operating systems may have different JSBridge implementations and support levels, leading to compatibility issues on different platforms. Developers need to adapt and debug for different platforms, increasing the complexity of development and maintenance.

[0004] 2. Security issues: JSBridge may introduce security risks, especially when native code execution is allowed. Malicious users may use JSBridge to conduct potential security attacks, such as code injection, cross-site scripting attacks, etc. Developers need to carefully handle input from the JavaScript side and implement appropriate security measures to protect the security of the application.

[0005] 3. Performance issues: The performance of JSBridge may be affected, especially during frequent communication between JavaScript and native code. Each communication requires serialization and deserialization operations, which may cause performance bottlenecks. Developers need to optimize the communication frequency and data transmission volume to improve the performance of the application.

[0006] The above technical problems lead to low interaction efficiency when Web and Native communicate via JSBridge.

[0007] Therefore, how to improve the interaction efficiency between Web and Native has become a technical problem that needs to be solved urgently. Summary of the invention

[0008] The present application provides a method, apparatus, device and medium for interaction between a Web end and a Native end based on a communication bridge, aiming to improve the interaction efficiency between the Web and the Native end.

[0009] In a first aspect, the present application provides a method for interaction between a Web end and a Native end based on a communication bridge, and the method for interaction between a Web end and a Native end based on a communication bridge comprises the following steps:

[0010] Build a target communication bridge between the Native side and the Web side;

[0011] When monitoring a function call request initiated by the Web end, generating interface call data based on the function call request;

[0012] Based on the target communication bridge, the interface call data is sent to the Native end, so that the Native end calls the corresponding interface method according to the interface call data, executes the target task corresponding to the function call request, and obtains the task execution result;

[0013] Based on the target communication bridge, the task execution result is sent to the Web end to respond to the function call request.

[0014] In a second aspect, the present application further provides a Web-side and Native-side interaction device based on a communication bridge, wherein the Web-side and Native-side interaction device based on a communication bridge comprises:

[0015] The communication bridge construction module is used to build a target communication bridge between the Native end and the Web end;

[0016] A request parsing module, configured to generate interface call data based on a function call request initiated by the Web end when monitoring the function call request;

[0017] A task execution module, used to send the interface call data to the Native end based on the target communication bridge, so that the Native end calls the corresponding interface method according to the interface call data, executes the target task corresponding to the function call request, and obtains the task execution result;

[0018] The request response module is used to send the task execution result to the Web end based on the target communication bridge to respond to the function call request.

[0019] In a third aspect, the present application also provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the method for interaction between the Web end and the Native end based on the communication bridge are implemented as described above.

[0020] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the method for interaction between a Web end and a Native end based on a communication bridge are implemented as described above.

[0021] The present application provides a method, apparatus, computer equipment and storage medium for interaction between a Web terminal and a Native terminal based on a communication bridge. The method of the present application includes building a target communication bridge between a Native terminal and a Web terminal;

[0022] When the function call request initiated by the Web end is monitored, interface call data is generated based on the function call request; based on the target communication bridge, the interface call data is sent to the Native end, so that the Native end calls the corresponding interface method according to the interface call data, executes the target task corresponding to the function call request, and obtains the task execution result; based on the target communication bridge, the task execution result is sent to the Web end to respond to the function call request. In the above manner, the present application enables the Web end to directly exchange data and call functions with the Native end by constructing a target communication bridge between the Native end and the Web end, eliminating the complexity and delay of communication between the Web end and the Native end, and improving the interaction efficiency between the Web and the Native end. By monitoring the function call requests initiated by the Web end and generating interface call data based on these requests, the accuracy and pertinence of the request are ensured, and unnecessary data processing and communication overhead are reduced. By using the target communication bridge to send the interface call data to the Native end, the Native end is allowed to directly execute the corresponding interface method, which can quickly respond to the request of the Web end and improve the speed and efficiency of task execution. Sending the task execution results back to the Web end through the target communication bridge ensures the instantaneous response, the accuracy and integrity of the data, and improves the reliability of the interaction between the Web and Native. By simplifying the communication process, improving data processing efficiency, and ensuring the accuracy of data transmission, the interaction efficiency between the Web and Native is significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0024] Figure 1 A flowchart of a first embodiment of a method for interaction between a Web terminal and a Native terminal based on a communication bridge provided by the present application;

[0025] Figure 2 A flowchart of a second embodiment of a method for interaction between a Web terminal and a Native terminal based on a communication bridge provided in this application;

[0026] Figure 3A flowchart of a third embodiment of a method for interaction between a Web terminal and a Native terminal based on a communication bridge provided by the present application;

[0027] Figure 4 It is a structural diagram of a first embodiment of a Web-side and Native-side interaction device based on a communication bridge provided by the present application;

[0028] Figure 5 It is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application.

[0029] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0030] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0031] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.

[0032] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0033] Please refer to Figure 1 , Figure 1 A flowchart of a first embodiment of a method for interaction between a Web terminal and a Native terminal based on a communication bridge provided in the present application.

[0034] like Figure 1 As shown, the method for interaction between the Web end and the Native end based on the communication bridge includes steps S101 to S104.

[0035] S101. Build a target communication bridge between the Native end and the Web end;

[0036] In one embodiment, the target communication bridge provided by the embodiment of the present application may be PikaBridge. PikaBridge is a plug-in commonly used in property insurance for WebView to bridge the communication between JavaScript / HTML5 pages and Native, which can be used to solve the problems encountered by JSBridge in actual project use to improve work efficiency.

[0037] Furthermore, an instance of the target communication bridge is constructed on the Native side, and the interface method corresponding to the instance is registered; a task execution function corresponding to the interface method is loaded on the Web side; and the target communication bridge is constructed based on the interface method and its corresponding task execution function.

[0038] Specifically, first define the communication interface, you can define the interface method that can be called by PikaBridge on the Native side, and define the JavaScript function corresponding to the Native side interface on the Web side. Then, initialize PikaBridge, initialize a PikaBridge instance on the Native side, register the corresponding interface method, load the PikaBridge script on the Web side, and initialize the bridge to communicate with the Native side.

[0039] Specifically, when the two ends communicate interactively, when the Web end needs to call the Native function, a JSON object containing the method name and parameters is sent through PikaBridge. On the Native end, listen to the message from the Web end and call the corresponding interface method according to the message content. After the task is completed, the interface method on the Native end returns the task execution result or error information to the Web end through PikaBridge. PikaBridge listens to the response from the Native end and passes the result to the JavaScript code on the Web end for processing.

[0040] It is understandable that in actual implementation, PikaBridge can achieve communication between Native and Web by injecting API, intercepting URLScheme or using JavaScriptCore library. For example, in Android, you can use the addJavascriptInterface method to inject a JavaScript object, and in iOS, you can use WKScriptMessageHandler to handle messages sent from JavaScript. On the Web side, you can communicate with the Native side by sending a specific URL request or directly calling the injected JavaScript function.

[0041] S102, when monitoring the function call request initiated by the Web end, generating interface call data based on the function call request;

[0042] In one embodiment, the Web end sends a JSON object containing the method name and parameters through PikaBridge (a hypothetical communication bridge tool). This JSON object will be encapsulated into a message and sent to the Native end through some mechanism (possibly HTTP request, WebSocket connection, local message queue, etc.).

[0043] Furthermore, based on the function call request, the task identifier of the target task is determined, and the task identifier includes the method name and configuration parameters of the interface method; based on a preset data processing algorithm, the task identifier is converted into a target format to obtain the interface call data.

[0044] In one embodiment, the task representation may include but is not limited to a method name and configuration parameters. The method name is the name of the interface method that needs to be called to execute the task, telling the Native end which specific operation needs to be performed. Configuration parameters refer to the input parameters required when executing the interface method, which may include user ID, operation type, data value, etc.

[0045] In one embodiment, when performing data format conversion through a data processing algorithm, data validation may be performed on the task identifier to ensure that all necessary parameters exist and are valid, and the parameters are converted into a format that the Native side can understand, for example, converting a string date into a date object, and then packaging the method name and parameters into a structured object or data format, such as a JSON object.

[0046] In one embodiment, the target format may be JSON.

[0047] Specifically, JSON is a lightweight data exchange format that is easy to understand and use. It uses a simple key-value pair structure and can represent a variety of data types, including strings, numbers, Boolean values, arrays, and objects, which makes it very simple to use JSON for data exchange.

[0048] Specifically, JSON is a universal data format, and almost all programming languages ​​support JSON parsing and generation. This means that using JSON for communication can achieve cross-platform compatibility. Whether on the Web or native mobile terminals, communication can be carried out by parsing and generating JSON data. Using JSON to communicate with native terminals eliminates the data encoding and decoding process, resulting in better performance and compatibility.

[0049] Furthermore, based on the function call request, the target configuration parameters of the interface method corresponding to the target task are determined; when the first configuration parameters are inconsistent with the current configuration parameters of the interface method, based on a preset configuration page, the current configuration parameters of the interface method are adjusted to the target configuration parameters to generate the interface call data.

[0050] Generally, background configuration is a method to dynamically adjust and configure system behavior through the background management interface. For PikaBridge, background configuration allows administrators to define and adjust interface methods, parameter configurations, and exception handling logic through the background management system without modifying the client code.

[0051] Specifically, background configuration refers to defining and managing the interface methods of PikaBridge and the dynamic parameter configuration of users calling PikaBridge through background configuration. It also supports the configuration of unified interface method exceptions. When the method is not found, the prompt upgrade logic can be uniformly processed. Background configuration allows the interface and behavior of PikaBridge to be dynamically configured in the background without modifying the client code. This allows the functionality of PikaBridge to be flexibly adjusted and expanded to meet different business needs without republishing and updating client applications. Background configuration can be applied to multiple platforms and client applications. Whether it is a Web application or a native mobile application, you only need to configure it according to its respective specifications and requirements to achieve a unified PikaBridge interface and behavior.

[0052] Specifically, a set of common interface specifications can be defined, including input parameters, output results, and error handling methods. This ensures that different interfaces follow the same format and specifications, facilitating unified management and calling. In the backend system, create a configuration management interface that allows developers or operators to dynamically configure interface methods, parameters, and behaviors. These configurations can be stored in a database or configuration file.

[0053] Specifically, through background configuration, PikaBridge can register new interface methods or discover configured interfaces at runtime without redeploying or compiling client applications.

[0054] Specifically, in the background configuration, a unified exception handling logic can be defined, including the specification of error codes and error messages. In this way, when the interface method is not found or other exceptions occur, they can be handled uniformly and the user can be prompted to perform corresponding operations.

[0055] In a specific implementation, developers or managers can use an administrator account to log in to the backend management system, find the configuration page of PikaBridge in the backend management system, and define or modify the interface method in the configuration page, which may include adding new methods, modifying the parameters or behaviors of existing methods, etc. For each interface method, dynamic parameters can be configured, which can be adjusted according to the input when the user calls. A unified interface method exception handling logic can be set, such as defining error codes, error messages, and upgrade logic when the method is not found. After the operation is completed, save all configuration changes. After the configuration is changed, test to ensure that the new configuration works as expected, such as calling the interface method and checking whether the return result is correct. If the test is successful, publish the configuration change to the production environment, and after the configuration change is released, monitor system performance and user feedback to ensure that the configuration change does not introduce new problems.

[0056] In this embodiment, the advantage of background configuration is that it provides flexibility and scalability, allowing system administrators to quickly respond to changes in business needs without waiting for the client application to be updated and republished. This method is applicable to a variety of platforms and client applications, including Web applications and native mobile applications, and a unified PikaBridge interface and behavior can be achieved by simply configuring them according to their respective specifications and requirements.

[0057] S103, based on the target communication bridge, sending the interface call data to the Native end, so that the Native end calls the corresponding interface method according to the interface call data, executes the target task corresponding to the function call request, and obtains the task execution result;

[0058] In one embodiment, the Native side can set a listener, which continuously listens for messages from the Web side. This listener can be a service or a background thread, and its task is to receive and parse messages sent from the Web side. Once the Native side receives the message, it will parse the JSON object and extract the method name and parameters. According to the parsed method name and parameters, the Native side calls the corresponding interface method to perform the task.

[0059] In one embodiment, after the task is executed, the Native end will encapsulate the execution result or error information into a new JSON object and send it back to the Web end through PikaBridge.

[0060] S104: Based on the target communication bridge, the task execution result is sent to the Web end to respond to the function call request.

[0061] In one embodiment, PikaBridge also has a listener on the Web side, which is responsible for listening to the response from the Native side. When the Native side sends a response, PikaBridge receives the response and passes the result to the JavaScript code on the Web side. After receiving the result from PikaBridge, the JavaScript code on the Web side parses the returned data and performs corresponding processing based on the result, such as updating the UI, displaying error information, etc.

[0062] In this embodiment, by building a target communication bridge, the technical solution ensures a stable and efficient communication channel between the Web and Native ends. When the Web initiates a function call request, the solution ensures the accuracy and executability of the request by generating interface call data, reducing communication errors caused by compatibility issues. At the same time, by optimizing data transmission and interface calls, the frequency of serialization and deserialization operations is reduced, thereby improving performance and solving performance bottleneck problems. In addition, the solution also ensures the real-time and responsiveness of the interaction by promptly feeding back the task execution results to the Web, further improving the interaction efficiency. In terms of security, by carefully handling input and implementing security measures, the potential risk of security attacks is reduced and the security of communication is ensured. Overall, this technical solution significantly improves the interaction efficiency between Web and Native by optimizing communication processes and enhancing security.

[0063] This embodiment provides a method for interaction between a Web end and a Native end based on a communication bridge. The method of this application enables the Web end to directly exchange data and call functions with the Native end by constructing a target communication bridge between the Native end and the Web end, thereby eliminating the complexity and delay of communication between the Web end and the Native end, and improving the interaction efficiency between the Web and the Native end. By monitoring the function call requests initiated by the Web end and generating interface call data based on these requests, the accuracy and pertinence of the requests are ensured, and unnecessary data processing and communication overhead are reduced. By using the target communication bridge to send the interface call data to the Native end, the Native end is allowed to directly execute the corresponding interface method, which can quickly respond to the request of the Web end and improve the speed and efficiency of task execution. The task execution results are sent back to the Web end through the target communication bridge, ensuring the immediacy of the response, ensuring the accuracy and integrity of the data, and improving the reliability of the interaction between the Web and the Native. By simplifying the communication process, improving the efficiency of data processing and ensuring the accuracy of data transmission, the interaction efficiency between the Web and the Native is significantly improved.

[0064] Please refer to Figure 2 , Figure 2A flowchart of a second embodiment of a method for interaction between a Web terminal and a Native terminal based on a communication bridge provided in this application.

[0065] In this embodiment, Figure 2 As shown, based on the above Figure 1 In the embodiment shown, the method further comprises:

[0066] S201, based on a data monitoring algorithm, monitoring and collecting the operation data of the target communication bridge to generate first log data, wherein the task execution data and operation performance data of the target communication bridge;

[0067] In one embodiment, the backend system can be configured to record the call log of PikaBridge, including request parameters, response results, execution time, etc. These log information can be used to monitor the status and performance of interface calls and optimize them. For example, if the response time of a certain interface is found to be too long, it may be necessary to optimize the performance of the interface or increase server resources to improve processing power.

[0068] Among them, log collection refers to adding a log recording function to the implementation of PikaBridge to collect and record the call and operation information of PikaBridge. Through log collection, key information such as the call process, parameters, and return values ​​of PikaBridge can be recorded.

[0069] In one embodiment, real-time monitoring of various key performance indicators of the communication bridge includes, but is not limited to, task execution data and operation performance data.

[0070] Specifically, the task execution data focuses on the ability of the communication bridge to complete specific tasks, such as the success rate of data transmission, the speed of task completion, and the error rate during task execution. These data help evaluate the efficiency and reliability of the communication bridge in practical applications.

[0071] Specifically, the operation performance data focuses more on the overall performance of the communication bridge during operation, including but not limited to the system response time, resource utilization (such as CPU and memory usage), network latency, and system stability. By monitoring these performance data, potential performance bottlenecks and system failures can be discovered in a timely manner, so that corresponding optimization measures can be taken.

[0072] In one embodiment, when implementing the data monitoring and collection process, a variety of data monitoring algorithms can be used, such as time series analysis, anomaly detection algorithms or machine learning models, to improve the accuracy and real-time performance of data collection.

[0073] Furthermore, based on a behavior analysis algorithm, data analysis is performed on the first log data to determine a user behavior pattern; and based on the user behavior pattern, an optimization evaluation plan for the target communication bridge is generated.

[0074] In one embodiment, by recording the call information of PikaBridge, the user's behavior and operation in the client application can be understood. These log data can be used for user behavior analysis, helping developers understand the user's usage habits and needs, thereby optimizing product functions and user experience.

[0075] Specifically, behavioral analysis algorithms are used to conduct in-depth analysis of these log data, recording the user's behavior and operations in the client application to determine the user's behavior pattern. For example, by configuring the backend system to record the call log of PikaBridge, including request parameters, response results, execution time and other information.

[0076] Generally speaking, the key to user behavior analysis is to collect data, analyze user paths, build user portraits, monitor indicators, and use analytical tools. Through these methods, we can understand in detail the usage habits and needs of different users for software products, thereby guiding product optimization and iteration. For example, through user behavior analysis, we can identify user preferences, optimize product functions, and improve user experience.

[0077] In one embodiment, based on the user behavior pattern, an optimization evaluation plan for the target communication bridge can be generated, including adjustments to product functions, improvements to the user interface, and performance enhancements. The purpose of the optimization evaluation plan is to improve the efficiency and user satisfaction of the communication bridge and ensure that it can better meet the needs and expectations of users. For example, through user behavior analysis, common problems and pain points of users when using the communication bridge can be discovered, and then targeted solutions can be proposed, such as simplifying the operation process, providing a more intuitive user interface design, and enhancing the stability and response speed of the system.

[0078] In addition, user behavior analysis can also reveal the degree of user dependence on the communication bridge and the frequency of use, which is also important for formulating market strategies and product development plans. By analyzing user behavior, future user needs can be predicted, so that new functions can be planned and developed in advance.

[0079] Through in-depth analysis of the first log data and determination of user behavior patterns, this embodiment can provide powerful data support and strategic guidance for the continuous optimization of the communication bridge, enhance user experience, and thus promote the long-term success of the product and the establishment of user loyalty.

[0080] S202: When an anomaly exists in the communication interaction data between the Web end and the Native end, an anomaly detection is performed on the first log based on an anomaly detection algorithm to determine an anomaly detection result, so as to perform fault maintenance according to the anomaly detection result.

[0081] In one embodiment, in the communication interaction between the Web end and the Native end, when an anomaly occurs in the communication data, an anomaly detection algorithm may be used to perform an in-depth analysis on the first log to determine the anomaly detection result, and perform fault maintenance accordingly.

[0082] In one embodiment, the anomaly detection algorithm can identify patterns that do not conform to expected behavior, which may be referred to as anomalies, outliers, inconsistent observations, etc. in different application fields. In the communication interaction between the Web and Native, anomalies may be caused by malicious activities, system failures, etc. Through log collection, information such as the execution time, resource consumption, and performance indicators of PikaBridge can be recorded. By analyzing these log data, the operating performance of PikaBridge can be understood, and performance optimization can be performed to improve the response speed of the application and user experience.

[0083] Optionally, when implementing anomaly detection, a variety of algorithms can be used, including but not limited to classification-based, nearest neighbor-based, clustering-based, and statistical techniques. These algorithms can be selected and adjusted based on factors such as the nature of the data, the availability of labeled data, the type of anomalies to be detected, etc. For example, for statistical techniques, different statistical models must be used for continuous and categorical data.

[0084] This embodiment can timely discover and maintain the communication interaction data between the Web end and the Native end by detecting anomalies in the log data, thereby ensuring the stability and reliability of the system.

[0085] Please refer to Figure 3 , Figure 3 A flowchart of a third embodiment of a method for interaction between a Web terminal and a Native terminal based on a communication bridge provided in this application.

[0086] In this embodiment, Figure 3 As shown, based on the above Figure 1 In the illustrated embodiment, before S101, the following further includes:

[0087] S301, creating a data virtual Mock server based on the interface specification of the Native end;

[0088] Generally speaking, integrated front-end Mock means integrating the front-end interface and data simulation (Mock) with JSBridge through the mechanism supported by JSBridge during the development and testing phase.

[0089] Specifically, you can collaborate with backend developers to define clear interface specifications, including request methods (GET, POST, etc.), request parameters, expected response data structures, etc. Use mock tools (such as Mock.js, Mirage.js, etc.) to build a mock server to simulate the response of the backend API. According to the interface specifications, create simulated response data that should cover various normal and abnormal business scenarios.

[0090] S302: Based on the communication mechanism of the target communication bridge, the Native end, the target communication bridge and the Mock server are integrated to generate an integrated front-end Mock, so as to test and verify the target communication bridge through the integrated front-end Mock.

[0091] In one embodiment, routing rules are configured on the Mock server to ensure that corresponding Mock data can be returned when the front end initiates a request. The address of the Mock server is configured in the front-end project so that the API called by the front end during the development process is actually a simulated interface on the Mock server.

[0092] In one embodiment, after the integrated front-end Mock is generated, the front-end developer can start development and testing work, using Mock data to verify the front-end logic and user interface. Take advantage of the flexibility of the Mock server to simulate different business scenarios and abnormal situations, such as network delays, data errors, permission issues, etc. When problems are encountered during the front-end development process, the problem can be quickly located through the logs and data of the Mock server. When the front-end development is nearing completion, an integration test with the native JSBridge is performed to ensure that the front-end code can correctly call the native method. Performance testing and boundary condition testing are performed in the Mock environment to ensure the performance of the application under high load and extreme conditions. Review the front-end code and perform necessary optimizations based on the test results. When the native API is ready, replace the Mock interface with the real back-end interface and perform a comprehensive integration test.

[0093] With the integrated front-end Mock, front-end developers can develop and test interfaces independently without waiting for the completion and deployment of native methods. This can improve development efficiency. The front-end Mock can generate simulated interface response data, allowing front-end developers to develop and test without interfaces. This can simulate various scenarios and data to better verify front-end logic and user interaction. The integrated front-end Mock can help front-end developers better debug and locate problems. When there is an interface call problem, you can quickly locate the problem by viewing the logs and data of the front-end Mock, thereby improving the efficiency of problem solving.

[0094] In this embodiment, the benefit of integrating the front-end Mock is that it allows the front-end development to be carried out independently of the back-end, so that parallel development can be achieved, which speeds up the development progress. At the same time, it also provides a safe environment to test various edge cases, improve code quality and user experience. In addition, Mock data can help developers understand business logic and better design user interfaces and interaction processes.

[0095] See also Figure 4 , Figure 4 It is a structural schematic diagram of a first embodiment of a Web-end and Native-end interaction device based on a communication bridge provided in the present application, and the Web-end and Native-end interaction device based on a communication bridge is used to execute the aforementioned Web-end and Native-end interaction method based on a communication bridge.

[0096] like Figure 4 As shown, the Web-side and Native-side interaction device 400 based on a communication bridge includes: a communication bridge construction module 401, a request parsing module 402, a task execution module 403 and a request response module 404.

[0097] The communication bridge construction module 401 is used to construct a target communication bridge between the Native end and the Web end;

[0098] The request parsing module 402 is used to generate interface call data based on the function call request when monitoring the function call request initiated by the Web end;

[0099] The task execution module 403 is used to send the interface call data to the Native end based on the target communication bridge, so that the Native end calls the corresponding interface method according to the interface call data, executes the target task corresponding to the function call request, and obtains the task execution result;

[0100] The request response module 404 is used to send the task execution result to the Web end based on the target communication bridge to respond to the function call request.

[0101] In one embodiment, the communication bridge construction module 401 includes:

[0102] An instance construction unit, used to construct an instance of the target communication bridge on the Native side, and register the interface method corresponding to the instance;

[0103] A function loading unit, used to load a task execution function corresponding to the interface method on the Web end;

[0104] The communication bridge construction unit is used to construct the target communication bridge based on the interface method and the corresponding task execution function.

[0105] In one embodiment, the request parsing module 402 includes:

[0106] A task identification determination unit, used to determine the task identification of the target task based on the function call request, wherein the task identification includes a method name and configuration parameters of the interface method;

[0107] The interface call data acquisition unit is used to convert the task identifier into a target format based on a preset data processing algorithm to obtain the interface call data.

[0108] In one embodiment, the request parsing module 402 further includes:

[0109] A configuration parameter determination unit, configured to determine, based on the function call request, a target configuration parameter of the interface method corresponding to the target task;

[0110] A parameter adjustment unit is used to adjust the current configuration parameters of the interface method to the target configuration parameters based on a preset configuration page when the first configuration parameters are inconsistent with the current configuration parameters of the interface method, and generate the interface call data.

[0111] In one embodiment, the communication bridge-based Web-side and Native-side interaction device 400 further includes a log collection module, including:

[0112] A log collection unit, configured to monitor and collect the operation data of the target communication bridge based on a data monitoring algorithm, and generate first log data, wherein the task execution data and operation performance data of the target communication bridge;

[0113] The anomaly detection unit is used to perform anomaly detection on the first log based on an anomaly detection algorithm when an anomaly exists in the communication interaction data between the Web end and the Native, and determine an anomaly detection result, so as to perform fault maintenance according to the anomaly detection result.

[0114] In one embodiment, the log collection module further includes:

[0115] A behavior analysis unit, configured to perform data analysis on the first log data based on a behavior analysis algorithm to determine a user behavior pattern;

[0116] The optimization evaluation unit is used to generate an optimization evaluation plan for the target communication bridge based on the user behavior pattern.

[0117] In one embodiment, the communication bridge-based Web-side and Native-side interaction device 400 further includes a virtual verification module, including:

[0118] A data virtual creation unit, used to create a data virtual Mock server based on the interface specification of the Native end;

[0119] The communication bridge verification unit is used to integrate the Native end, the target communication bridge and the Mock server based on the communication mechanism of the target communication bridge to generate an integrated front-end Mock, so as to test and verify the target communication bridge through the integrated front-end Mock.

[0120] It should be noted that technical personnel in the relevant field can clearly understand that for the convenience and conciseness of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned embodiment of the Web-side and Native-side interaction method based on the communication bridge, and will not be repeated here.

[0121] The apparatus provided in the above embodiment may be implemented in the form of a computer program. The computer program may be Figure 5 Runs on the computer device shown.

[0122] See also Figure 5 , Figure 5 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server.

[0123] See also Figure 5 The computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.

[0124] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any method for interacting between the Web end and the Native end based on the communication bridge.

[0125] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.

[0126] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any method for interacting between the Web end and the Native end based on the communication bridge.

[0127] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will appreciate that Figure 5The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0128] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0129] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:

[0130] Build a target communication bridge between the Native side and the Web side;

[0131] When monitoring a function call request initiated by the Web end, generating interface call data based on the function call request;

[0132] Based on the target communication bridge, the interface call data is sent to the Native end, so that the Native end calls the corresponding interface method according to the interface call data, executes the target task corresponding to the function call request, and obtains the task execution result;

[0133] Based on the target communication bridge, the task execution result is sent to the Web end to respond to the function call request.

[0134] In one embodiment, the processor, when implementing the building of the target communication bridge between the Native end and the Web end, is used to implement:

[0135] Constructing an instance of the target communication bridge on the Native side, and registering the interface method corresponding to the instance;

[0136] Loading a task execution function corresponding to the interface method on the Web end;

[0137] Based on the interface method and the corresponding task execution function, the target communication bridge is constructed.

[0138] In one embodiment, when the processor generates the interface call data based on the function call request, it is used to implement:

[0139] Based on the function call request, determining a task identifier of the target task, wherein the task identifier includes a method name and configuration parameters of the interface method;

[0140] Based on a preset data processing algorithm, the task identifier is converted into a target format to obtain the interface call data.

[0141] In one embodiment, when the processor generates the interface call data based on the function call request, it is further used to implement:

[0142] Based on the function call request, determining target configuration parameters of the interface method corresponding to the target task;

[0143] When the first configuration parameter is inconsistent with the current configuration parameter of the interface method, based on a preset configuration page, the current configuration parameter of the interface method is adjusted to the target configuration parameter to generate the interface call data.

[0144] In one embodiment, when the processor runs the computer program, it is further configured to implement:

[0145] Based on the data monitoring algorithm, the operation data of the target communication bridge is monitored and collected to generate first log data, wherein the task execution data and operation performance data of the target communication bridge are;

[0146] When there is an anomaly in the communication interaction data between the Web end and the Native, an anomaly detection is performed on the first log based on an anomaly detection algorithm to determine an anomaly detection result, so as to perform fault maintenance according to the anomaly detection result.

[0147] In one embodiment, after the processor implements the data monitoring algorithm to monitor and collect the operation data of the target communication bridge and generates the first log data, it is further configured to implement:

[0148] Based on a behavior analysis algorithm, performing data analysis on the first log data to determine a user behavior pattern;

[0149] Based on the user behavior pattern, an optimization evaluation plan for the target communication bridge is generated.

[0150] In one embodiment, the processor is further used to implement, before implementing, upon monitoring the function call request initiated by the Web end, generating an interface call number based on the function call request:

[0151] Based on the interface specification of the Native end, create a data virtual Mock server;

[0152] Based on the communication mechanism of the target communication bridge, the Native end, the target communication bridge and the Mock server are integrated to generate an integrated front-end Mock, so as to test and verify the target communication bridge through the integrated front-end Mock.

[0153] A computer-readable storage medium is also provided in an embodiment of the present application, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the processor executes the program instructions to implement any one of the Web-side and Native-side interaction methods based on a communication bridge provided in an embodiment of the present application.

[0154] The computer-readable storage medium may be an internal storage unit of the computer device described in the above embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), etc. equipped on the computer device.

[0155] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for interaction between a Web end and a Native end based on a communication bridge, characterized in that: The method comprises: Build a target communication bridge between the Native side and the Web side; When monitoring a function call request initiated by the Web end, generating interface call data based on the function call request; Based on the target communication bridge, the interface call data is sent to the Native end, so that the Native end calls the corresponding interface method according to the interface call data, executes the target task corresponding to the function call request, and obtains the task execution result; Based on the target communication bridge, the task execution result is sent to the Web end to respond to the function call request.

2. The method for interacting between a Web terminal and a Native terminal based on a communication bridge according to claim 1, characterized in that: The target communication bridge is constructed between the Native end and the Web end, including: Constructing an instance of the target communication bridge on the Native side, and registering the interface method corresponding to the instance; Loading a task execution function corresponding to the interface method on the Web end; Based on the interface method and the corresponding task execution function, the target communication bridge is constructed.

3. The method for interacting between a Web terminal and a Native terminal based on a communication bridge according to claim 1, characterized in that: The generating interface call data based on the function call request includes: Based on the function call request, determining a task identifier of the target task, wherein the task identifier includes a method name and configuration parameters of the interface method; Based on a preset data processing algorithm, the task identifier is converted into a target format to obtain the interface call data.

4. The method for interacting between a Web terminal and a Native terminal based on a communication bridge according to claim 1, characterized in that: The generating interface call data based on the function call request further includes: Based on the function call request, determining target configuration parameters of the interface method corresponding to the target task; When the first configuration parameter is inconsistent with the current configuration parameter of the interface method, based on a preset configuration page, the current configuration parameter of the interface method is adjusted to the target configuration parameter to generate the interface call data.

5. The method for interacting between a Web terminal and a Native terminal based on a communication bridge according to claim 1, characterized in that: The method further comprises: Based on the data monitoring algorithm, the operation data of the target communication bridge is monitored and collected to generate first log data, wherein the task execution data and operation performance data of the target communication bridge are; When there is an anomaly in the communication interaction data between the Web end and the Native, an anomaly detection is performed on the first log based on an anomaly detection algorithm to determine an anomaly detection result, so as to perform fault maintenance according to the anomaly detection result.

6. The method for interaction between a Web terminal and a Native terminal based on a communication bridge according to claim 5, characterized in that: The method further includes monitoring and collecting the operation data of the target communication bridge based on the data monitoring algorithm and generating the first log data: Based on a behavior analysis algorithm, performing data analysis on the first log data to determine a user behavior pattern; Based on the user behavior pattern, an optimization evaluation plan for the target communication bridge is generated.

7. The method for interacting between a Web terminal and a Native terminal based on a communication bridge according to claim 1, characterized in that: When the function call request initiated by the Web end is monitored, before generating the interface call number based on the function call request, the method further includes: Based on the interface specification of the Native end, create a data virtual Mock server; Based on the communication mechanism of the target communication bridge, the Native end, the target communication bridge and the Mock server are integrated to generate an integrated front-end Mock, so as to test and verify the target communication bridge through the integrated front-end Mock.

8. A Web-side and Native-side interaction device based on a communication bridge, characterized in that: The Web-side and Native-side interaction device based on the communication bridge includes: The communication bridge construction module is used to build a target communication bridge between the Native end and the Web end; A request parsing module, configured to generate interface call data based on a function call request initiated by the Web end when monitoring the function call request; A task execution module, used to send the interface call data to the Native end based on the target communication bridge, so that the Native end calls the corresponding interface method according to the interface call data, executes the target task corresponding to the function call request, and obtains the task execution result; The request response module is used to send the task execution result to the Web end based on the target communication bridge to respond to the function call request.

9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the method for interaction between the Web end and the Native end based on a communication bridge are implemented as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the method for interaction between a Web end and a Native end based on a communication bridge as described in any one of claims 1 to 7 are implemented.