Communication method and device of hybrid application program, electronic equipment and storage medium
By sending error event information from the webpage to the native end in a hybrid application, and notifying the webpage after processing on the native end, the problem of untimely error handling when the webpage is called the native bridge on the webpage is solved, and the stability and user experience of the application are improved.
Patent Information
- Application Number
- CN202411779006.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-03-28
AI Technical Summary
When existing hybrid applications call native bridges on the web side, they cannot detect and handle errors in time, resulting in reduced stability and user experience.
When the call to the native bridge on the web side fails, the error event information is sent to the native side, so that the native side can handle the error in time, and notify the web side after the error is fixed to continue calling the native bridge.
It realizes timely discovers and handles errors in the process of calling the native bridge of the web page, and improves the stability and user experience of hybrid applications.
Smart Images

Figure CN119719550A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a communication method, device, electronic device and storage medium for a hybrid application. Background Art
[0002] A hybrid application (Hybrid Application, Hybrid App) is a software application that combines elements of both native applications and web applications. Due to permission and security restrictions, when using a hybrid application, the web side of the hybrid application often needs to call the services of its native side. The successful call of the native bridge of the native side by the web side is a prerequisite for the web side to call the services of the native side.
[0003] Currently, most web pages call native bridges through JavaScript. However, the communication between JavaScript and native code is an asynchronous operation, which makes it impossible for the native end to know whether the web page has successfully called its native bridge. It is not until the hybrid application exits abnormally or fails to function that the errors in the calling process are manually found and handled. The timeliness of error discovery and handling is poor, which reduces the customer experience.
[0004] How to promptly detect and handle errors in the process of the web page calling the native bridge of the native side, and improve the stability of hybrid applications and user experience, has become an urgent problem to be solved. Summary of the invention
[0005] The main purpose of the embodiments of the present application is to propose a communication method, device, electronic device and storage medium for a hybrid application, aiming to improve the stability of the hybrid application and the user's usage experience.
[0006] To achieve the above-mentioned purpose, the first aspect of an embodiment of the present application proposes a communication method for a hybrid application, which is applied to the native end of the hybrid application, including: receiving information about a first error event sent by the web page end of the hybrid application when calling the native bridge of the native end fails; the first error event is an error event related to the native end that occurs in a first process; the first process is the process of the web page end calling the native bridge of the native end; processing the first error event according to the information of the first error event; and sending a notification to the web page end that the first error event has been repaired when it is obtained that the first error event has been repaired, so that the web page end can continue to call the native bridge.
[0007] In some embodiments, the processing of the first error event based on the information of the first error event includes any of the following: displaying the information of the first error event so that the developer of the hybrid application can repair the first error event based on the information of the first error event; using a first repair strategy to repair the first error event; and / or recording the information of the first error event in the error log of the native end so that the developer of the hybrid application can repair the first error event based on the information of the first error event; the first repair strategy is a repair strategy corresponding to the information of the first error event.
[0008] In some embodiments, after sending a notification to the web page that the first error event has been repaired, the communication method also includes: executing a target business operation in response to a target business call instruction sent by the web page through the native bridge; in the event of failure to execute the target business operation, sending information about a second error event to the web page so that the web page processes the second error event based on the information about the second error event; the second error event is an error event related to the web page that occurs in a second process; the second process is a process for executing the target business operation; and in the event of receiving a notification sent by the web page that the second error event has been repaired, returning to the step of executing the target business operation until the target business operation is successfully executed.
[0009] In some embodiments, before sending the information of the second error event to the web page, the communication method also includes: monitoring the second process; when a third error event is monitored to occur in the second process, determining a first target object for processing the third error event based on the information of the third error event; the third error event is an error event occurring in the second process; and when the first target object is the web page, determining the third error event as the second error event.
[0010] To achieve the above-mentioned purpose, the second aspect of an embodiment of the present application proposes a communication method for a hybrid application, which is applied to the web page end of the hybrid application, including: calling the native bridge of the native end of the hybrid application; in the event of failure to call the native bridge, sending information about a first error event to the native end so that the native end processes the first error event based on the information about the first error event; the first error event is an error event related to the native end that occurs in a first process; the first process is a process of calling the native bridge; in the event of receiving a notification sent by the native end that the first error event has been repaired, returning to execute the step of calling the native bridge of the native end of the hybrid application until the call to the native bridge is successful.
[0011] In some embodiments, before sending the information of the first error event to the native end, the communication method also includes: monitoring the first process; in the case of monitoring that a fourth error event occurs in the first process, determining a second target object for processing the fourth error event based on the information of the fourth error event; the fourth error event is an error event occurring in the first process; and in the case that the second target object is the native end, determining the fourth error event as the first error event.
[0012] In some embodiments, after the step of calling the native bridge of the native end of the hybrid application, the communication method also includes: in the case where the native bridge is called successfully, sending a target business call instruction to the native end through the native bridge, so that the native end performs a target business operation according to the target business call instruction; in the case of receiving information about a second error event sent by the native end, processing the second error event according to the information of the second error event; the second error event is an error event related to the web page that occurs in the second process; the second process is a process in which the native end performs the target business operation according to the target business call instruction; in the case of obtaining that the second error event has been repaired, sending a notification to the native end that the second error event has been repaired, so that the native end continues to perform the target business operation.
[0013] In some embodiments, the processing of the second error event based on the information of the second error event includes any of the following: displaying the information of the second error event so that the developer of the hybrid application can repair the second error event based on the information of the second error event; and / or recording the information of the second error event in the error log of the web page so that the developer of the hybrid application can repair the second error event based on the information of the second error event; using a second repair strategy to repair the second error event; the second repair strategy is a repair strategy corresponding to the information of the second error event.
[0014] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes a communication device for a hybrid application, the device comprising: a first receiving module, a first processing module and a first sending module; the first receiving module is used to receive information about a first error event sent by the web page end of the hybrid application when calling the native bridge of the native end fails; the first error event is an error event related to the native end that occurs in the first process; the first process is the process of the web page end calling the native bridge of the native end; the first processing module is used to process the first error event according to the information of the first error event; the first sending module is used to send a notification to the web page end that the first error event has been repaired when it is obtained that the first error event has been repaired, so that the web page end can continue to call the native bridge.
[0015] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a communication device for a hybrid application, the device comprising: a first calling module, a second sending module and a second receiving module; the first calling module is used to call the native bridge of the native end of the hybrid application; the second sending module is used to send information about a first error event to the native end when calling the native bridge fails, so that the native end can process the first error event according to the information of the first error event; the first error event is an error event related to the native end that occurs in a first process; the first process is a process of calling the native bridge; the second receiving module is used to return to the step of calling the native bridge of the native end of the hybrid application when receiving a notification sent by the native end that the first error event has been repaired, until the native bridge is successfully called.
[0016] To achieve the above-mentioned purpose, the fifth aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the method described in the first aspect or the second aspect when executing the computer program.
[0017] To achieve the above objectives, the sixth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect or the second aspect is implemented.
[0018] The communication method, device, electronic device and storage medium of the hybrid application proposed in the present application, when the web page end of the hybrid application fails to call the native bridge of its native end, the information of the first error event is sent to the native end through the web page end, so that the native end can promptly discover the error information of the native bridge calling process, and further process the first error event according to the information of the first error event through the native end, so that the error of the native bridge calling process can be processed in time, and the abnormal exit or functional failure of the hybrid application can be avoided, which can improve the stability of the hybrid application and the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flow chart of a communication method of a hybrid application provided in an embodiment of the present application;
[0020] Figure 2 is another flowchart of the communication method of the hybrid application provided in the embodiment of the present application;
[0021] Figure 3 It is a structural schematic diagram of a communication device for a hybrid application provided in an embodiment of the present application;
[0022] Figure 4 is another structural schematic diagram of a communication device for a hybrid application provided in an embodiment of the present application;
[0023] Figure 5 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0024] Figure 6 It is another hardware structure diagram of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0026] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0028] The embodiments of the present application provide a communication method, device, electronic device and storage medium for a hybrid application, aiming to improve the stability of the hybrid application and the user's usage experience.
[0029] The communication method, device, electronic device and storage medium of the hybrid application provided in the embodiments of the present application are specifically described through the following embodiments. First, the communication method of the hybrid application in the embodiments of the present application is described.
[0030] The communication method of the hybrid application provided in the embodiment of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the communication method of the hybrid application, etc., but is not limited to the above forms.
[0031] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0032] Figure 1 It is an optional flowchart of the communication method of the hybrid application provided in the embodiment of the present application. Figure 1 The communication method of the hybrid application in the present invention is applied to the native end of the hybrid application and may include but is not limited to steps S101 to S103.
[0033] Step S101: receiving information about a first error event sent by a web page of a hybrid application when calling a native bridge of a native side fails; the first error event is an error event related to the native side that occurs in a first process; the first process is a process in which the web page calls the native bridge of the native side;
[0034] Step S102: Processing the first error event according to information of the first error event;
[0035] Step S103: When it is obtained that the first error event has been repaired, a notification that the first error event has been repaired is sent to the web page so that the web page can continue to call the native bridge.
[0036] In steps S101 to S103 shown in the embodiment of the present application, when the web page end of the hybrid application fails to call the native bridge of its native end, the information of the first error event is sent to the native end through the web page end, so that the native end can promptly discover the error information of the native bridge calling process, and further process the first error event according to the information of the first error event through the native end, so that the error of the native bridge calling process can be handled in time, and the abnormal exit or functional failure of the hybrid application can be avoided, which can improve the stability of the hybrid application and the user experience.
[0037] Optionally, the first error event may be one error event or multiple error events, and the information of the first error event includes the type of the first error event and the cause of occurrence. The first error event may include, but is not limited to: an error event in which the web page end calls an undefined function because the native end does not correctly pass the injection class instance to the web page end, and an error event in which the web page end cannot find the calling function because the native end does not annotate and match the native bridge. For the error event in which the web page end calls an undefined function because the native end does not correctly pass the injection class instance to the web page end, the type is undefined calling function, and the cause is that the native end does not correctly pass the injection class instance to the web page end; for the error event in which the web page end cannot find the calling function because the native end does not annotate and match the native bridge, the type is undefined calling function, and the cause is that the native end does not annotate and match the native bridge.
[0038] In one implementation, the above step S102: processing the first error event according to information of the first error event, includes any of the following:
[0039] Displaying information about the first error event so that the developer of the hybrid application can fix the first error event based on the information about the first error event; and / or recording information about the first error event in an error log of the native end so that the developer of the hybrid application can fix the first error event based on the information about the first error event;
[0040] A first repair strategy is adopted to repair the first error event; the first repair strategy is a repair strategy corresponding to information of the first error event.
[0041] Optionally, the native end stores repair strategies corresponding to various error events. When the native end receives information about a first error event sent by the web page end, the first repair strategy corresponding to the information about the first error event can be determined by querying the correspondence between the error event and the repair strategy, and the first repair strategy obtained can be used to repair the first error event.
[0042] Optionally, the information of the first error event also includes a first repair strategy for the first error event. When the native end receives the information of the first error event sent by the webpage end, the first repair strategy carried in the information of the first error event can be used to repair the first error event.
[0043] Optionally, the above-mentioned recording of the information of the first error event to the error log of the native end includes any of the following items: recording the information of the first error event to the error log stored locally on the native end; recording the information of the first error event to the error log of the native end stored in the server.
[0044] Optionally, when the native end displays the information of the first error event and / or records the information of the first error event in the error log of the native end, the situation that the first error event has been repaired can be obtained by obtaining the repaired information sent by the hybrid application developer, and the repaired information can be automatically generated and sent by the hybrid application developer triggering a fixed button; when the native end adopts the first repair strategy to repair the first error event, the situation that the first error event has been repaired can be obtained by the native end obtaining the repair result of the first error event.
[0045] In the embodiment of the present application, upon receiving the information of the first error event sent by the web page, the native end displays the information of the first error event and / or records the information of the first error event in the error log of the native end. This can facilitate the developers of the hybrid application to perform troubleshooting and analysis based on the information of the first error event, help to speed up the speed of locating and repairing error events in the process of the web page calling the native bridge, and can improve the development or maintenance efficiency of the hybrid application. In addition, upon receiving the information of the first error event sent by the web page, the native end adopts the first repair strategy to directly repair the first error event, which can further speed up the speed of locating and repairing error events in the process of the web page calling the native bridge, and can further improve the development or maintenance efficiency of the hybrid application, thereby avoiding abnormal exit or functional failure of the hybrid application, and further improving the stability of the hybrid application and the user experience.
[0046] Optionally, in the above step S103, in order for the web page to continue to call the native bridge, the web page can call the native bridge again, which is equivalent to the first error event causing the current process of the web page calling the native bridge to be terminated. After the first error event is repaired, the web page needs to restart the steps of calling the native bridge; or in order for the web page to continue to call the native bridge, which is equivalent to the first error event causing the current process of the web page calling the native bridge to be terminated. After the first error event is repaired, the web page can continue to execute the steps of the first error event occurring in the process of calling the native bridge and its subsequent steps. The specific steps can be determined according to the actual business situation.
[0047] In one embodiment, after sending a notification that the first error event has been fixed to the web page in the above step S103, the communication method of the hybrid application provided in the embodiment of the present application further includes:
[0048] In response to the target service call instruction sent by the web page through the native bridge, execute the target service operation;
[0049] In the case of failure in executing the target business operation, information of the second error event is sent to the web page end so that the web page end processes the second error event according to the information of the second error event; the second error event is an error event related to the web page end that occurs in the second process; the second process is a process of executing the target business operation;
[0050] When receiving the notification that the second error event has been fixed sent by the web page, return to the step of executing the target business operation until the target business operation is successfully executed.
[0051] Optionally, the second error event can be one error event or multiple error events. Optionally, the return to execute the target business operation can be to return to re-execute the target business operation, which is equivalent to the second error event causing the native end to terminate the current process of executing the target business operation. After the second error event is repaired, the native end needs to restart the steps of executing the target business operation from the beginning; it can also be to return to continue to execute the target business operation, which is equivalent to the second error event causing the native end to terminate the current process of executing the target business operation. After the second error event is repaired, the native end can continue to execute the steps and subsequent steps of the second error event that occurred during the execution of the target business operation. The specific steps can be determined according to the actual business situation.
[0052] In the embodiment of the present application, when the web page successfully calls the native bridge of the native end, the native end responds to the target business call instruction sent by the web page through the native bridge to execute the target business operation, and when the target business operation fails, the native end sends information about the second error event in the process of executing the target business operation to the web page so that the web page can process the second error event and continue to execute the target business operation after receiving the notification of the repaired second error event sent by the web page. This helps to speed up the positioning and repair of error events in the process of executing the target business operation by the native end, and can improve the development or maintenance efficiency of hybrid applications, thereby avoiding abnormal exit or functional failure of hybrid applications, and further improving the stability of hybrid applications and the user experience.
[0053] In one embodiment, before sending the information of the second error event to the web page, the communication method of the hybrid application provided by the embodiment of the present application further includes:
[0054] receiving information about a first reported error event, where the first reported error event is an error event discovered and submitted by a developer of the hybrid application during a process in which the native end executes a target business operation;
[0055] Determine, according to information of the first reported error event, a target object for processing the first reported error event;
[0056] When the target object for processing the first error reporting event is a web page, the first error reporting event is determined as a second error event.
[0057] The information of the first reported error event includes at least the type and cause of the first reported error event, and may also include a repair strategy for the first reported error event. The repair strategy for the first reported error event can be determined by querying the correspondence between the error event and the repair strategy on the native end.
[0058] In one embodiment, before sending the information of the second error event to the web page, the communication method of the hybrid application provided by the embodiment of the present application further includes:
[0059] Monitoring the second process;
[0060] In the case of monitoring that a third error event occurs in the second process, determining a first target object for processing the third error event according to information of the third error event; the third error event is an error event that occurs in the second process;
[0061] When the first target object is a web page, the third error event is determined as the second error event.
[0062] The information of the third error event at least includes the type and cause of the third error event, and may also include a repair strategy for the third error event. The repair strategy for the third error event can be determined by querying the correspondence between the error event and the repair strategy on the native end.
[0063] Optionally, determining the first target object for processing the third error event based on information of the third error event includes: determining the first target object for processing the third error event based on at least one of a type, a cause, and a repair strategy of the third error event.
[0064] The above-mentioned third error event may include but is not limited to: object reference failure, parameter type mismatch, and business logic error. Among them, object reference failure is an error related to the native end. The reason for its occurrence is that the native end object is released or cleaned up in the life cycle management, causing the native end to access an empty object or invalid reference during execution. The repair strategy is to add a null value check in the native bridge, and perform internal processing or return failure information when an invalid reference is found to prevent the web page from exiting abnormally. Parameter type mismatch is an error related to the web page. The reason for its occurrence is that the parameter type passed by the web page does not meet the requirements of the native bridge. The repair strategy is that the web page repairs the parameter type passed to ensure that the parameter type passed matches the requirements of the native bridge. Business logic error is an error related to the web page. The reason for its occurrence may be that the number of operations allowed by the business exceeds the number of operations allowed. The repair strategy is to perform business operations within the allowed number of operations.
[0065] In the case where the above-mentioned first target object is a web page, the native end can send the type and cause of the corresponding third error event (i.e., the second error event) to the web page, so that the web page can repair the second error event based on the repair strategy queried according to the type and cause of the second error event; the type, cause and repair strategy of the second error event can also be sent to the web page, so that the web page can repair the third error event based on the repair strategy carried in the third error event.
[0066] In the case where the above-mentioned first target object is the native end, the native end repairs the third error event according to the repair strategy corresponding to the third error event; the information of the third error event may also be displayed so that the developer of the hybrid application can repair the third error event based on the information of the third error event; and / or the information of the third error event may be recorded in the error log of the native end so that the developer of the hybrid application can repair the third error event based on the information of the third error event.
[0067] The embodiment of the present application monitors the process of the native end executing the target business operation, and when the third error event is monitored and the first target object for processing the third error event is the web page, the third error event is determined as the second error event. This can improve the efficiency and accuracy of the native end in identifying the second error event related to the web page during the process of executing the target business operation, help speed up the positioning and repair of error events in the process of the native end executing the target business operation, and can improve the development or maintenance efficiency of hybrid applications, thereby avoiding abnormal exit or functional failure of hybrid applications, and further improving the stability of the hybrid applications and the user experience.
[0068] Figure 2 This is another optional flowchart of the communication method of the hybrid application provided in the embodiment of the present application. Figure 2 The communication method of the hybrid application in the embodiment is applied to the web page of the hybrid application and may include but is not limited to steps S201 to S203.
[0069] Step S201: calling the native bridge of the native end of the hybrid application;
[0070] Step S202: in the case of failure in calling the native bridge, sending information of the first error event to the native end, so that the native end processes the first error event according to the information of the first error event; the first error event is an error event related to the native end occurring in the first process; the first process is a process of calling the native bridge;
[0071] Step S203: upon receiving the notification of the first error event being fixed sent by the native end, returning to the step of calling the native bridge of the native end of the hybrid application until the calling of the native bridge succeeds.
[0072] In steps S201 to S203 shown in the embodiment of the present application, when the web page end of the hybrid application fails to call the native bridge of its native end, the information of the first error event is sent to the native end through the web page end, so that the native end can promptly discover and process the error information of the native bridge calling process, avoid abnormal exit or functional failure of the hybrid application, and improve the stability of the hybrid application and the user experience.
[0073] Optionally, the step of returning to execute the native bridge of the native end of the hybrid application in the above step S203 can be returning to re-execute the step of calling the native bridge, which is equivalent to the first error event causing the above step S201 to be terminated. After the first error event is repaired, the web page needs to restart the above step S201; it can also be returning to continue to execute the step of calling the native bridge of the native end of the hybrid application, which is equivalent to the first error event causing the above step S201 to be terminated. After the first error event is repaired, the web page can continue to execute the step of the first error event and its subsequent steps during the process of executing the above step S201. The specific steps can be determined according to the actual business situation.
[0074] In one implementation, before sending the information of the first error event to the native end in the above step S202, the communication method of the hybrid application provided in the embodiment of the present application further includes:
[0075] receiving information about a second reported error event, where the second reported error event is an error event discovered and submitted by a developer of the hybrid application during a process in which the web page calls the native bridge;
[0076] Determine, according to the information of the second reported error event, a target object for processing the second reported error event;
[0077] When the target object for processing the second error reporting event is the native end, the second error reporting event is determined as the first error event.
[0078] The information of the second reported error event includes at least the type and cause of the second reported error event, and may also include a repair strategy for the second reported error event. The repair strategy for the second reported error event can be determined by querying the correspondence between the error event and the repair strategy on the web page.
[0079] In one implementation, before sending the information of the first error event to the native end in the above step S202, the communication method of the hybrid application provided in the embodiment of the present application further includes:
[0080] Monitoring the first process;
[0081] In the case of monitoring that a fourth error event occurs in the first process, determining a second target object for processing the fourth error event according to information of the fourth error event; the fourth error event is an error event that occurs in the first process;
[0082] When the second target object is a native end, the fourth error event is determined as the first error event.
[0083] The information of the fourth error event includes at least the type and cause of the fourth error event, and may also include a repair strategy for the fourth error event. Optionally, the web page stores a correspondence between each error event and a repair strategy, and the repair strategy for the fourth error event can be determined by querying the correspondence between the error event and the repair strategy on the web page.
[0084] Optionally, the determining, according to the information of the fourth error event, a second target object for processing the fourth error event includes:
[0085] A second target object for processing the fourth error event is determined according to at least one of a type, a cause of occurrence, and a repair strategy of the fourth error event.
[0086] The fourth error event mentioned above may include but is not limited to: the calling function is not defined, the calling function cannot be found, and the interface permissions are insufficient or restricted. Among them, the calling function is not defined is an error related to the native end, and the reason for its occurrence is that the web page end attempts to call an undefined function. The repair strategy is that the native end correctly passes the injection class instance to the web page end. The calling function cannot be found is an error related to the native end. The reason for its occurrence is that the web page end attempts to call a variable of a non-function type. The repair strategy is that the native end annotates and matches the type of the native bridge. Insufficient or restricted interface permissions are errors related to the web page end. The reason for its occurrence is that the interface is not correctly registered and / or the interface usage environment is unsafe. The repair strategy is to correctly register the Javascript interface and / or use the Javascript interface in a secure context.
[0087] In the case where the above-mentioned second target object is the native end, the web page end can send the type and cause of the corresponding fourth error event (i.e., the first error event) to the native end, so that the native end can repair the first error event according to the repair strategy queried based on the type and cause of the first error event; the type, cause and repair strategy of the first error event can also be sent to the native end, so that the native end can repair the first error event according to the repair strategy carried in the first error event.
[0088] In the case where the above-mentioned first target object is the web page, the native end repairs the fourth error event according to the repair strategy corresponding to the fourth error event; the information of the fourth error event may also be displayed so that the developer of the hybrid application can repair the fourth error event based on the information of the fourth error event; and / or the information of the fourth error event may be recorded in the error log of the web page so that the developer of the hybrid application can repair the fourth error event based on the information of the fourth error event.
[0089] The embodiment of the present application monitors the process of the web page calling the native bridge, and when the fourth error event is monitored and the second target object for processing the fourth error event is the native end, the fourth error event is determined as the first error event. This can improve the efficiency and accuracy of the web page in identifying the first error event related to the native end in the process of calling the native bridge, help speed up the positioning and repair of error events in the process of calling the native bridge, and improve the development or maintenance efficiency of hybrid applications, thereby avoiding abnormal exit or functional failure of hybrid applications, and further improving the stability of hybrid applications and user experience.
[0090] In one implementation, after the above step S201: calling the native bridge of the native end of the hybrid application, the communication method of the hybrid application provided by the embodiment of the present application further includes:
[0091] When the native bridge is successfully called, a target service calling instruction is sent to the native end through the native bridge, so that the native end executes the target service operation according to the target service calling instruction;
[0092] When receiving information about a second error event sent by the native end, processing the second error event according to the information about the second error event; the second error event is an error event related to the web page that occurs in the second process; the second process is a process in which the native end executes a target business operation according to a target business call instruction;
[0093] When it is obtained that the second error event has been repaired, a notification that the second error event has been repaired is sent to the native end so that the native end continues to execute the target service operation.
[0094] Optionally, the above-mentioned enabling the native end to continue to perform the target business operation can be enabling the native end to re-perform the target business operation, which is equivalent to the second error event causing the current process of the native end performing the target business operation to be terminated, and after the second error event is repaired, the native end needs to restart the steps of performing the target business operation from the beginning; or enabling the native end to continue to perform the target business operation, which is equivalent to the second error event causing the current process of the native end performing the target business operation to be terminated, and after the second error event is repaired, the native end can continue to perform the steps and subsequent steps of the second error event occurring during the process of performing the target business operation. The specific details can be determined according to the actual business situation.
[0095] In the embodiment of the present application, when the native bridge of the native end is successfully called, the web page sends a target business call instruction to the native end through the native bridge, and when the information of the second error event sent by the native end is received, the second error event is processed according to the information of the second error event, and when it is obtained that the second error event has been repaired, a notification of the repaired second error event is sent to the native end. This helps to speed up the speed of locating and repairing error events in the process of the native end executing the target business operation, and can improve the development or maintenance efficiency of hybrid applications, thereby avoiding abnormal exit or functional failure of hybrid applications, and further can improve the stability of the hybrid applications and the user experience.
[0096] In one implementation, the processing of the second error event according to the information of the second error event includes any one of the following:
[0097] Displaying information about the second error event so that the developer of the hybrid application can fix the second error event based on the information about the second error event; and / or recording information about the second error event in an error log on the web page so that the developer of the hybrid application can fix the second error event based on the information about the second error event;
[0098] The second error event is repaired using a second repair strategy; the second repair strategy is a repair strategy corresponding to information of the second error event.
[0099] Optionally, when the web page receives information about the second error event sent by the native end, the second repair strategy corresponding to the information about the second error event can be determined by querying the correspondence between the error event and the repair strategy, and the queried second repair strategy can be used to repair the second error event.
[0100] Optionally, the second error event information also includes a second repair strategy for the second error event. When the web page receives the second error event information sent by the native end, the second error event can be repaired using the second repair strategy carried in the second error event information.
[0101] Optionally, the above-mentioned recording of the information of the second error event into the error log of the web page includes any of the following items: recording the information of the second error event into the error log stored locally on the web page; recording the information of the second error event into the error log of the web page stored in the server.
[0102] Optionally, when the web page displays information about the second error event and / or records the information about the second error event in the error log of the web page, the situation that the second error event has been repaired is obtained by the developer of the hybrid application sending a repair instruction; when the web page adopts the second repair strategy to repair the second error event, the situation that the second error event has been repaired is obtained by the web page obtaining the repair result of the second error event.
[0103] In the embodiment of the present application, when the information of the second error event sent by the native end is received, the web page displays the information of the second error event, and / or records the information of the second error event in the error log of the web page. This can facilitate the developers of the hybrid application to perform troubleshooting and analysis based on the information of the second error event, help to speed up the speed of locating and repairing error events in the process of the native end performing the target business operation, and can improve the development or maintenance efficiency of the hybrid application. In addition, when the information of the second error event sent by the native end is received, the web page adopts the second repair strategy to directly repair the second error event, which can further speed up the speed of locating and repairing error events in the process of the native end performing the target business operation, and can further improve the development or maintenance efficiency of the hybrid application, thereby avoiding abnormal exit or functional failure of the hybrid application, and further improving the stability of the hybrid application and the user experience.
[0104] See also Figure 3 , the embodiment of the present application also provides a hybrid application communication device 300, which can implement the above hybrid application communication method, the device includes: a first receiving module 301, a first processing module 302 and a first sending module 303;
[0105] The first receiving module 301 is used to receive information about a first error event sent by the web page of the hybrid application when calling the native bridge of the native end fails; the first error event is an error event related to the native end that occurs in the first process; the first process is the process of the web page calling the native bridge of the native end;
[0106] The first processing module 302 is used to process the first error event according to information of the first error event;
[0107] The first sending module 303 is used to send a notification that the first error event has been repaired to the web page end when it is obtained that the first error event has been repaired, so that the web page end continues to call the native bridge.
[0108] The specific implementation of the communication device of the hybrid application is basically the same as the specific implementation of the communication method of the hybrid application mentioned above, and will not be repeated here.
[0109] See also Figure 4 The embodiment of the present application also provides a communication device 400 for a hybrid application, which can implement the communication method of the above-mentioned hybrid application. The device includes: a first calling module 401, a second sending module 402 and a second receiving module 403.
[0110] The first calling module 401 is used to call the native bridge of the native end of the hybrid application;
[0111] The second sending module 402 is used to send information about the first error event to the native end when the calling of the native bridge fails, so that the native end processes the first error event according to the information about the first error event; the first error event is an error event related to the native end that occurs in the first process; the first process is a process of calling the native bridge;
[0112] The second receiving module 403 is used to return to the step of calling the native bridge of the native end of the hybrid application program when receiving the notification of the first error event being fixed sent by the native end, until the calling of the native bridge succeeds.
[0113] The specific implementation of the communication device of the hybrid application is basically the same as the specific implementation of the communication method of the hybrid application mentioned above, and will not be repeated here.
[0114] like Figure 5 As shown, the embodiment of the present application further provides an electronic device 500, including a processor 501 and a memory 502, the memory 502 stores a program or instruction that can be run on the processor 501, and the program or instruction is executed by the processor 501 to implement the various steps of the communication method embodiment of the above-mentioned hybrid application, and can achieve the same technical effect, to avoid repetition, it is not repeated here. It should be noted that the electronic device in the embodiment of the present application includes the above-mentioned mobile electronic device and non-mobile electronic device.
[0115] See also Figure 6 , Figure 6 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0116] The processor 601 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0117] The memory 602 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 602 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 602, and the processor 601 calls and executes the communication method of the hybrid application in the embodiment of this application;
[0118] Input / output interface 603, used to implement information input and output;
[0119] Communication interface 604, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0120] Bus 605 , which transmits information between various components of the device (e.g., processor 601 , memory 602 , input / output interface 603 , and communication interface 604 );
[0121] The processor 601 , the memory 602 , the input / output interface 603 and the communication interface 604 are connected to each other in communication within the device via a bus 605 .
[0122] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the communication method of the above-mentioned hybrid application.
[0123] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0124] The communication method, device, electronic device and storage medium of the hybrid application provided in the embodiments of the present application, when the web page end of the hybrid application fails to call the native bridge of its native end, the web page end sends information of a first error event to the native end, so that the native end can promptly discover and handle errors in the process of the web page end calling the native bridge, and when the web page end calls the native bridge successfully but the native end fails to execute the target business operation, the native end sends information of a second error event in the process of executing the target business operation to the web page end, so that the web page end can promptly discover and handle errors in the process of the native end executing the target business, which can improve the development or maintenance efficiency of the hybrid application, thereby avoiding abnormal exit or functional failure of the hybrid application, and further improving the stability of the hybrid application and the user experience.
[0125] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0126] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0127] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0128] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0129] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0130] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0131] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0132] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0133] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0134] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0135] The preferred embodiments of the present application are described above with reference to the accompanying drawings, but the scope of the rights of the present application is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present application should be within the scope of the rights of the present application.
Claims
1. A communication method for a hybrid application, characterized in that: The native side applied to the hybrid application includes: Receive information about a first error event sent by the web page of the hybrid application when calling the native bridge of the native end fails; the first error event is an error event related to the native end that occurs in a first process; the first process is a process in which the web page calls the native bridge of the native end; Processing the first error event according to information about the first error event; When it is obtained that the first error event has been repaired, a notification that the first error event has been repaired is sent to the web page end so that the web page end continues to call the native bridge.
2. The communication method according to claim 1, characterized in that: The processing of the first error event according to the information of the first error event includes any one of the following: Displaying information about the first error event so that a developer of the hybrid application can repair the first error event based on the information about the first error event; and / or recording information of the first error event into an error log of the native end so that a developer of the hybrid application can repair the first error event based on the information of the first error event; Using a first repair strategy to repair the first error event; The first repair strategy is a repair strategy corresponding to the information of the first error event.
3. The communication method according to claim 1, wherein: After sending a notification to the webpage indicating that the first error event has been repaired, the communication method further includes: In response to a target service call instruction sent by the web page through the native bridge, executing a target service operation; In the case of failure in executing the target business operation, information of a second error event is sent to the web page end so that the web page end processes the second error event according to the information of the second error event; the second error event is an error event related to the web page end that occurs in a second process; the second process is a process of executing the target business operation; When receiving the notification sent by the web page that the second error event has been repaired, return to the step of executing the target business operation until the target business operation is successfully executed.
4. The communication method according to claim 3, characterized in that: Before sending the information of the second error event to the webpage, the communication method further includes: monitoring the second process; In the case of monitoring that a third error event occurs in the second process, determining a first target object for processing the third error event according to information of the third error event; the third error event is an error event occurring in the second process; When the first target object is the web page, the third error event is determined as the second error event.
5. A communication method for a hybrid application, characterized in that: The web page end applied to the hybrid application includes: A native bridge that calls a native side of the hybrid application; In the case of failure in calling the native bridge, sending information of a first error event to the native end so that the native end processes the first error event according to the information of the first error event; the first error event is an error event related to the native end occurring in a first process; the first process is a process of calling the native bridge; In case of receiving the notification sent by the native end that the first error event has been repaired, returning to execute the step of calling the native bridge of the native end of the hybrid application until the calling of the native bridge is successful.
6. The communication method according to claim 5, characterized in that: Before sending the information of the first error event to the native end, the communication method further includes: Monitoring the first process; In the case of monitoring that a fourth error event occurs in the first process, determining a second target object for processing the fourth error event according to information of the fourth error event; the fourth error event is an error event occurring in the first process; When the second target object is the native end, the fourth error event is determined as the first error event.
7. The communication method according to claim 5, characterized in that: After the step of calling the native bridge of the native end of the hybrid application, the communication method further comprises: In the case where the native bridge is successfully called, a target service calling instruction is sent to the native end through the native bridge, so that the native end performs the target service operation according to the target service calling instruction; In the case of receiving information about a second error event sent by the native end, processing the second error event according to the information about the second error event; the second error event is an error event related to the web page end that occurs in the second process; the second process is a process in which the native end executes the target business operation according to the target business call instruction; When it is obtained that the second error event has been repaired, a notification that the second error event has been repaired is sent to the native end so that the native end continues to execute the target service operation.
8. A communication device for a hybrid application, characterized in that: include: A first receiving module, a first processing module and a first sending module; The first receiving module is used to receive information about a first error event sent by the web page of the hybrid application when calling the native bridge of the native end fails; the first error event is an error event related to the native end that occurs in the first process; The first process is a process in which the web page side calls the native bridge of the native side; The first processing module is used to process the first error event according to information of the first error event; The first sending module is used for sending a notification that the first error event has been repaired to the web page end when it is obtained that the first error event has been repaired, so that the web page end can continue to call the native bridge.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the communication method of the hybrid application according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the communication method of the hybrid application according to any one of claims 1 to 7 is implemented.