Service strip line data interaction method and device, electronic equipment and storage medium
Through JavaScript Bridge SDK, data interaction between H5 and Native is realized in financial APPs, which solves the problems of data capacity limit, low security and slow transmission speed of URL Scheme method, and provides an efficient, safe and flexible data transmission method. , supports the transfer of complex data types, reducing development costs.
Patent Information
- Application Number
- CN202410741815.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-27
AI Technical Summary
In financial apps, the URL Scheme method is used for data interaction between business line modules. There are problems such as limited data capacity, low security, high coupling, inability to transmit complex data types, and slow transmission speed.
Through the JavaScript Bridge SDK, the window.webkit.messageHandlers object is used to call the registered message handler to realize data interaction between H5 and Native. The evaluateJavaScript method of WKWebView is used for message transmission. It supports the transmission of complex data types and is established through the WKScriptMessageHandler protocol. Communication bridge.
It achieves the security, efficiency and flexibility of data transmission, supports the transmission of complex data types, reduces development costs, and solves the problems of low data transmission efficiency, insecurity and inflexible use of existing methods.
Smart Images

Figure CN118708288A
Abstract
Description
Technical Field
[0001] The present application relates to the field of financial technology, and specifically, to a business line data interaction method, device, electronic device and storage medium. Background Art
[0002] Financial apps generally involve many business areas. To make a financial app into a super app, it is necessary to connect with various business parties and integrate all business systems. Hybrid development is generally adopted in technology selection, that is, Hybrid App (hybrid application). Hybrid development is an open model that refers to the use of multiple development models to develop apps. There is a technical difficulty in hybrid development (Hybrid App), that is, it is difficult to achieve data interaction between different business line modules. The usual solution is: Use URL Scheme to transfer data between different business pages. By constructing a specific URL, data can be carried when jumping to another page. The target page can parse the parameters in the URL and perform corresponding processing.
[0003] The URL Scheme method for data communication in a Hybrid App has the following disadvantages:
[0004] Limited data capacity: The capacity of URL Scheme to transmit data is limited, usually limited by the length limit of the URL. If a large amount of data needs to be transmitted, it may exceed the limit of the URL, resulting in data loss or truncation.
[0005] Low data security: The data transmitted by the URL Scheme is exposed in the URL in plain text, so there is a security risk. Malicious users may intercept the URL and obtain sensitive data.
[0006] Dependence on a specific URL format: The URL Scheme method requires the definition of a specific URL format to transmit data, which needs to be agreed upon and parsed between different pages. This dependency may lead to some coupling and maintenance issues.
[0007] Unable to directly pass complex data types: The data passed by URL Scheme is usually in string form. It is impossible to directly pass complex data types such as objects and arrays, and serialization and deserialization operations are required.
[0008] Slow transmission speed: Compared with other data communication methods, the speed of data transmission using URL Scheme is slow. Each time data is transmitted, it is necessary to construct a URL, parse the URL, and process parameters, which affects performance. Summary of the invention
[0009] The purpose of the embodiments of the present application is to provide a business line data interaction method, device, electronic device and storage medium, which can directly call JavaScript methods through JavaScript bridge SDK to achieve interaction with H5 pages, have flexible scalability and safe and efficient data transmission, and solve the problems of low data transmission efficiency, insecurity and inflexible use of existing methods.
[0010] The present application provides a method for data interaction of a business line, the method comprising:
[0011] The JavaScript bridge SDK calls the registered message handler in the first business line through the window.webkit.messageHandlers object to send a message to the first business line;
[0012] The first business line receives messages from the JavaScript bridge SDK through the WKScriptMessageHandler protocol;
[0013] The first business line parses and executes the parameters in the message to obtain an execution result;
[0014] The first business line returns the execution result to the JavaScript bridge SDK through the evaluateJavaScript method of WKWebView, so that the execution result is sent to the second business line through the JavaScript bridge SDK.
[0015] In the above implementation process, the JavaScript Bridge SDK can be used to easily realize data communication between H5 and Native, and data communication between H5 and H5. The SDK provides advantages such as direct calling of JavaScript methods, support for complex data types, powerful functional scalability, high-performance data transmission and flexible business scalability, making the interaction between Native code and H5 pages more convenient and powerful, and convenient for developers to develop, greatly saving development costs, and solving the problems of low efficiency, insecurity and inflexible use of data transmission in existing methods.
[0016] Furthermore, before the step of the JavaScript bridge SDK calling the registered message handler in the first business line through the window.webkit.messageHandlers object, the method further includes:
[0017] Create a WKWebView object and add it to the first business line;
[0018] Configure parameters for the WKWebView object for being called by the JavaScript bridge SDK.
[0019] In the above implementation process, the WKWebView object is configured so that JavaScript can call native Objective-C / Swift code.
[0020] Furthermore, the configuration parameters of the WKWebView object include:
[0021] Set the proxy and UserAgent parameters for the WKWebView object.
[0022] In the above implementation process, specific configuration parameters include setting proxy, setting UserAgent, etc., and can be adjusted according to needs, which is flexible and convenient.
[0023] Furthermore, before the step of the JavaScript bridge SDK calling the registered message handler in the first business line through the window.webkit.messageHandlers object, the method further includes:
[0024] Creating a bridge class based on the WKScriptMessageHandler protocol in the first business line to serve as a communication bridge between the first business line and the JavaScript bridge SDK;
[0025] Register the bridge class as a WKWebView-based message handler.
[0026] In the above implementation, the bridge class is registered as a message processor to receive messages from JavaScript.
[0027] The embodiment of the present application also provides a business line data interaction device, the device comprising:
[0028] A message sending module, used by the JavaScript bridge SDK to call the registered message handler in the first business line through the window.webkit.messageHandlers object to send a message to the first business line;
[0029] A message receiving module, used for the first business line to receive messages from the JavaScript bridge SDK through the WKScriptMessageHandler protocol;
[0030] A parsing module, used for the first business line to parse the parameters in the message and execute the message to obtain an execution result;
[0031] The result sending module is used for the first business line to return the execution result to the JavaScript bridge SDK through the evaluateJavaScript method of WKWebView, so as to send the execution result to the second business line through the JavaScript bridge SDK.
[0032] In the above implementation process, the JavaScript Bridge SDK can be used to easily realize data communication between H5 and Native, and data communication between H5 and H5. The SDK provides advantages such as direct calling of JavaScript methods, support for complex data types, powerful functional scalability, high-performance data transmission and flexible business scalability, making the interaction between Native code and H5 pages more convenient and powerful, and convenient for developers to develop, greatly saving development costs, and solving the problems of low efficiency, insecurity and inflexible use of data transmission in existing methods.
[0033] Furthermore, the device also includes:
[0034] An object creation module, used to create a WKWebView object and add it to the first business line;
[0035] The parameter configuration module is used to configure parameters of the WKWebView object for being called by the JavaScript bridge SDK.
[0036] In the above implementation process, the WKWebView object is configured so that JavaScript can call native Objective-C / Swift code.
[0037] The parameter configuration module includes:
[0038] The proxy parameter configuration module is used to set the proxy and UserAgent parameters for the WKWebView object.
[0039] In the above implementation process, specific configuration parameters include setting proxy, setting UserAgent, etc., and can be adjusted according to needs, which is flexible and convenient.
[0040] Furthermore, the device also includes:
[0041] A bridge class creation module, used to create a bridge class based on the WKScriptMessageHandler protocol in the first business line, used to serve as a communication bridge between the first business line and the JavaScript bridge SDK;
[0042] The message processor registration module is used to register the bridge class as a message processor based on WKWebView.
[0043] In the above implementation, the bridge class is registered as a message processor to receive messages from JavaScript.
[0044] An embodiment of the present application also provides an electronic device, which includes a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute any of the above-mentioned business line data interaction methods.
[0045] An embodiment of the present application further provides a readable storage medium, wherein the readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, any of the above-mentioned business line data interaction methods is executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 A flowchart of a business line data interaction method provided in an embodiment of the present application;
[0048] Figure 2 An architectural diagram of the JavaScript bridge SDK provided in the embodiment of the present application;
[0049] Figure 3 A message processor registration flow chart for the first business line provided in an embodiment of the present application;
[0050] Figure 4 A structural block diagram of a business line data interaction device provided in an embodiment of the present application;
[0051] Figure 5 A structural block diagram of another business line data interaction device provided in an embodiment of the present application.
[0052] icon:
[0053] 100-message sending module; 110-object creation module; 120-parameter configuration module; 121-agent parameter configuration module; 130-bridge class creation module; 140-message processor registration module; 200-message receiving module; 300-parsing module; 400-result sending module. DETAILED DESCRIPTION
[0054] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0055] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0056] Example 1
[0057] Please see Figure 1 , Figure 1 A flowchart of a business line data interaction method provided in an embodiment of the present application. The method uses JavaScript Bridge SDK to achieve communication between native and JavaScript. JavaScript Bridge SDK is an SDK module developed by native. It can receive data from H5. JavaScript Bridge SDK receives data from H5 and stores it in native when appropriate.
[0058] This method can directly call JavaScript methods through the JavaScript bridge SDK to achieve interaction with the H5 page. It has flexible scalability and safe and efficient data transmission, which solves the problems of low data transmission efficiency, insecurity and inflexible use of existing methods.
[0059] The method specifically comprises the following steps:
[0060] Step S100: JavaScript bridge SDK (Software Development Kit) calls the registered message handler in the first business line through the window.webkit.messageHandlers object (an instance object of the browser) to send a message to the first business line;
[0061] JavaScript interacts with native: In JavaScript, the registered message handler is called through the window.webkit.messageHandlers object, and a message is sent to the native. The parameters can be passed in JSON format. window.webkit.messageHandlers is a method called by JS on the H5 side to transmit data to the native, which is received here through Bridge.
[0062] like Figure 2 The following is the architecture diagram of JavaScript Bridge SDK. H5-1 represents the first business line, H5-2 represents the second business line, Native is native development, JavaScript Bridge SDK is developed in native language, and provides JS interface for calling.
[0063] like Figure 3 The figure shows a flow chart of message processor registration for the first service line. Before step S100, the method further includes the following steps:
[0064] Step S110: creating a WKWebView object and adding it to the first business line;
[0065] Specifically, create WKWebView: In iOS system, use the WKWebView class provided by the WebKit framework to load and display WebView content. Create a WKWebView object and add it to the view hierarchy. Each business line is an H5 page, which is loaded and rendered by WKWebView. Data communication is simply: H5 page Page1 stores "data" in the native through Bridge, calls H5 page Page2, gets "data" from the native, and uses it later.
[0066] Step S120: configuring parameters for the WKWebView object so as to be called by the JavaScript bridge SDK.
[0067] Configure the corresponding parameters for WKWebView, including setting the proxy, setting the UserAgent, etc. These configurations can be adjusted according to specific needs, which is flexible and convenient.
[0068] Through the configuration of WKWebView, JavaScript can call native Objective-C / Swift code. Through the JavaScript Bridge SDK, JS in the H5 page can easily call native methods.
[0069] Step S130: creating a bridge class based on the WKScriptMessageHandler protocol in the first business line, used as a communication bridge between the first business line and the JavaScript bridge SDK;
[0070] Specifically, in the native code, create a class that follows the WKScriptMessageHandler protocol as a bridge for JavaScript to communicate with the native code.
[0071] Step S140: register the bridge class as a message processor based on WKWebView.
[0072] Register a JavaScript message handler: Register the bridge class in the previous step as the WKWebView message handler to receive messages sent from JavaScript.
[0073] Step S200: The first business line receives a message from the JavaScript bridge SDK through the WKScriptMessageHandler protocol;
[0074] Step S300: the first business line parses the parameters in the message and executes the message to obtain an execution result;
[0075] Step S400: The first business line returns the execution result to the JavaScript bridge SDK through the evaluateJavaScript method of WKWebView, so as to send the execution result to the second business line through the JavaScript bridge SDK.
[0076] This method can easily realize data communication between H5 and Native through JavaScript Bridge SDK, and convenient data communication between H5 and H5. SDK provides advantages such as direct calling of JavaScript methods, support for complex data types, powerful functional scalability, high-performance data transmission and flexible business scalability, making the interaction between Native code and H5 pages more convenient and powerful, and convenient for developers to develop, greatly saving development costs, and solving the problems of low efficiency, insecurity and inflexible use of data transmission methods in existing methods.
[0077] Native interaction with JavaScript: In native code, receive messages from JavaScript by implementing methods in the WKScriptMessageHandler protocol. Native code can parse the parameters in the message and execute the corresponding logic. If you need to return results to JavaScript, you can execute JavaScript code through the evaluateJavaScript method of WKWebView and pass the results to JavaScript. evaluateJavaScript is a method called by native code to execute a JS method in the H5 page, using methods such as webview.evaluateJavaScript(script).
[0078] Using JavaScript Bridge to communicate data in a Hybrid App has the following advantages:
[0079] Directly call JavaScript methods: Through JavaScript Bridge, you can directly call JavaScript methods in Native code to achieve interaction with H5 (Html5) pages. This makes it easy to pass data between business layers, call specific functions, or perform specific operations;
[0080] Support for complex data types: Compared with URL Scheme and other methods, JavaScript Bridge can directly pass complex data types, such as objects, arrays, etc. This allows for more flexible data transfer and processing;
[0081] Powerful functional extensibility: JavaScript Bridge can establish a two-way communication channel between Native code and JavaScript, and can provide rich functional interfaces in the Native layer for H5 pages to call, so as to give full play to the characteristics and functions of the native platform and provide more capabilities for H5 pages;
[0082] High-performance data transfer: Compared with methods such as URL Scheme, JavaScript Bridge is usually more efficient in data transfer. By directly calling JavaScript methods, the overhead of parsing URLs and constructing parameters can be reduced, improving the speed and performance of data transfer;
[0083] Flexible business scalability: JavaScript Bridge can better support business expansion and changes. By adding or modifying the JavaScript Bridge interface, business functions can be flexibly adjusted and expanded without affecting the Native code.
[0084] Therefore, the JavaScript Bridge SDK described in this application can easily realize data communication between H5 and Native, and convenient data communication between H5 and H5. SDK provides advantages such as direct calling of JavaScript methods, support for complex data types, powerful functional scalability, high-performance data transmission, and flexible business scalability, making the interaction between Native code and H5 pages more convenient and powerful, facilitating development by developers, and greatly saving development costs.
[0085] Example 2
[0086] The embodiment of the present application provides a business line data interaction device, which is applied to the business line data interaction method in embodiment 1. The device uses JavaScript Bridge SDK to realize communication between native and JavaScript. JavaScript Bridge SDK is an SDK module developed by native. It can receive data from H5. JavaScript Bridge SDK receives data from H5 and stores it in native when appropriate.
[0087] The device can directly call JavaScript methods through the JavaScript bridge SDK to achieve interaction with the H5 page. It has flexible scalability and safe and efficient data transmission, which solves the problems of low data transmission efficiency, insecurity and inflexible use of existing methods.
[0088] like Figure 4 The figure shows a structural block diagram of a business line data interaction device.
[0089] The device includes but is not limited to:
[0090] A message sending module 100, used by the JavaScript bridge SDK to call a registered message handler in the first business line through the window.webkit.messageHandlers object to send a message to the first business line;
[0091] JavaScript interacts with native: In JavaScript, the registered message handler is called through the window.webkit.messageHandlers object, and a message is sent to the native. The parameters can be passed in JSON format. window.webkit.messageHandlers is a method called by JS on the H5 side to transmit data to the native, which is received here through Bridge.
[0092] A message receiving module 200, used for the first business line to receive messages from the JavaScript bridge SDK through the WKScriptMessageHandler protocol;
[0093] A parsing module 300, configured for the first business line to parse parameters in the message and execute the parameters to obtain an execution result;
[0094] The result sending module 400 is used for the first business line to return the execution result to the JavaScript bridge SDK through the evaluateJavaScript method of WKWebView, so as to send the execution result to the second business line through the JavaScript bridge SDK.
[0095] The device can easily realize data communication between H5 and Native, and convenient data communication between H5 and H5 through JavaScript Bridge SDK. The SDK provides advantages such as direct calling of JavaScript methods, support for complex data types, powerful functional scalability, high-performance data transmission and flexible business scalability, making the interaction between Native code and H5 pages more convenient and powerful, and convenient for developers to develop, greatly saving development costs, and solving the problems of low efficiency, insecurity and inflexible use of data transmission methods in existing methods.
[0096] like Figure 5 FIG. 1 is a block diagram of another business line data interaction device. The device also includes:
[0097] The object creation module 110 is used to create a WKWebView object and add it to the first business line;
[0098] Specifically, create WKWebView: In iOS system, use the WKWebView class provided by the WebKit framework to load and display WebView content. Create a WKWebView object and add it to the view hierarchy. Each business line is an H5 page, which is loaded and rendered by WKWebView. Data communication is simply: H5 page Page1 stores "data" in the native through Bridge, calls H5 page Page2, gets "data" from the native, and uses it later.
[0099] The parameter configuration module 120 is used to configure parameters of the WKWebView object for being called by the JavaScript bridge SDK.
[0100] Configure the corresponding parameters for WKWebView, including setting the proxy, setting the UserAgent, etc. These configurations can be adjusted according to specific needs, which is flexible and convenient.
[0101] Through the configuration of WKWebView, JavaScript can call native Objective-C / Swift code. Through the JavaScript Bridge SDK, JS in the H5 page can easily call native methods.
[0102] The parameter configuration module 120 includes:
[0103] The proxy parameter configuration module 121 is used to set the proxy and UserAgent parameters for the WKWebView object.
[0104] Specific configuration parameters include setting proxy, setting UserAgent, etc., and can be adjusted according to needs, which is flexible and convenient.
[0105] The device also includes:
[0106] A bridge class creation module 130, used to create a bridge class based on the WKScriptMessageHandler protocol in the first business line, used to serve as a communication bridge between the first business line and the JavaScript bridge SDK;
[0107] Specifically, in the native code, create a class that follows the WKScriptMessageHandler protocol as a bridge for JavaScript to communicate with the native code.
[0108] The message processor registration module 140 is used to register the bridge class as a message processor based on WKWebView.
[0109] Register a JavaScript message handler: Register the bridge class in the previous step as the WKWebView message handler to receive messages sent from JavaScript.
[0110] Native interaction with JavaScript: In native code, receive messages from JavaScript by implementing methods in the WKScriptMessageHandler protocol. Native code can parse the parameters in the message and execute the corresponding logic. If you need to return results to JavaScript, you can execute JavaScript code through the evaluateJavaScript method of WKWebView and pass the results to JavaScript. evaluateJavaScript is a method called by native code to execute a JS method in the H5 page, using methods such as webview.evaluateJavaScript(script).
[0111] Using JavaScript Bridge to communicate data in a Hybrid App has the following advantages:
[0112] Directly call JavaScript methods: Through JavaScript Bridge, you can directly call JavaScript methods in Native code to achieve interaction with H5 (Html5) pages. This makes it easy to pass data between business layers, call specific functions, or perform specific operations;
[0113] Support for complex data types: Compared with URL Scheme and other methods, JavaScript Bridge can directly pass complex data types, such as objects, arrays, etc. This allows for more flexible data transfer and processing;
[0114] Powerful functional extensibility: JavaScript Bridge can establish a two-way communication channel between Native code and JavaScript, and can provide rich functional interfaces in the Native layer for H5 pages to call, so as to give full play to the characteristics and functions of the native platform and provide more capabilities for H5 pages;
[0115] High-performance data transfer: Compared with methods such as URL Scheme, JavaScript Bridge is usually more efficient in data transfer. By directly calling JavaScript methods, the overhead of parsing URLs and constructing parameters can be reduced, improving the speed and performance of data transfer;
[0116] Flexible business scalability: JavaScript Bridge can better support business expansion and changes. By adding or modifying the JavaScript Bridge interface, business functions can be flexibly adjusted and expanded without affecting the Native code.
[0117] Therefore, the JavaScript Bridge SDK described in this application can easily realize data communication between H5 and Native, and convenient data communication between H5 and H5. SDK provides advantages such as direct calling of JavaScript methods, support for complex data types, powerful functional scalability, high-performance data transmission, and flexible business scalability, making the interaction between Native code and H5 pages more convenient and powerful, facilitating development by developers, and greatly saving development costs.
[0118] An embodiment of the present application also provides an electronic device, which includes a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the business line data interaction method described in Example 1.
[0119] JavaScript Bridge SDK can be used to easily realize data communication between H5 and Native, and data communication between H5 and H5. The SDK provides advantages such as direct calling of JavaScript methods, support for complex data types, powerful functional scalability, high-performance data transmission and flexible business scalability, making the interaction between Native code and H5 pages more convenient and powerful, and convenient for developers to develop, greatly saving development costs, and solving the problems of low efficiency, insecurity and inflexible use of data transmission methods in existing methods.
[0120] An embodiment of the present application further provides a readable storage medium, in which computer program instructions are stored. When the computer program instructions are read and executed by a processor, the business line data interaction method described in Embodiment 1 is executed.
[0121] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0122] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0123] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0124] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0125] 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 changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0126] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A business line data interaction method, It is characterized in that The method comprises: The JavaScript bridge SDK calls the registered message handler in the first business line through the window.webkit.messageHandlers object to send a message to the first business line; The first business line receives messages from the JavaScript bridge SDK through the WKScriptMessageHandler protocol; The first business line parses and executes the parameters in the message to obtain an execution result; The first business line returns the execution result to the JavaScript bridge SDK through the evaluateJavaScript method of WKWebView, so that the execution result is sent to the second business line through the JavaScript bridge SDK.
2. The business line data interaction method according to claim 1, It is characterized in that Before the step of the JavaScript bridge SDK calling the registered message handler in the first service line through the window.webkit.messageHandlers object, the method further includes: Create a WKWebView object and add it to the first business line; Configure parameters for the WKWebView object for being called by the JavaScript bridge SDK.
3. The business line data interaction method according to claim 1, It is characterized in that The configuration parameters of the WKWebView object include: Set the proxy and UserAgent parameters for the WKWebView object.
4. The business line data interaction method according to claim 1, It is characterized in that Before the step of the JavaScript bridge SDK calling the registered message handler in the first service line through the window.webkit.messageHandlers object, the method further includes: Creating a bridge class based on the WKScriptMessageHandler protocol in the first business line to serve as a communication bridge between the first business line and the JavaScript bridge SDK; Register the bridge class as a WKWebView-based message handler.
5. A business line data interaction device, It is characterized in that The device comprises: A message sending module, used by the JavaScript bridge SDK to call the registered message handler in the first business line through the window.webkit.messageHandlers object to send a message to the first business line; A message receiving module, used for the first business line to receive messages from the JavaScript bridge SDK through the WKScriptMessageHandler protocol; A parsing module, used for the first business line to parse the parameters in the message and execute the message to obtain an execution result; The result sending module is used for the first business line to return the execution result to the JavaScript bridge SDK through the evaluateJavaScript method of WKWebView, so as to send the execution result to the second business line through the JavaScript bridge SDK.
6. The business line data interaction device according to claim 5, It is characterized in that The device also includes: An object creation module, used to create a WKWebView object and add it to the first business line; The parameter configuration module is used to configure parameters of the WKWebView object for being called by the JavaScript bridge SDK.
7. The business line data interaction device according to claim 6, It is characterized in that The parameter configuration module includes: The proxy parameter configuration module is used to set the proxy and UserAgent parameters for the WKWebView object.
8. The business line data interaction device according to claim 5, It is characterized in that The device also includes: A bridge class creation module, used to create a bridge class based on the WKScriptMessageHandler protocol in the first business line, used to serve as a communication bridge between the first business line and the JavaScript bridge SDK; The message processor registration module is used to register the bridge class as a message processor based on WKWebView.
9. An electronic device, It is characterized in that The electronic device includes a memory and a processor, the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the business line data interaction method according to any one of claims 1 to 4.
10. A readable storage medium, It is characterized in that The readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, the business line data interaction method according to any one of claims 1 to 4 is executed.
Citation Information
Cited By
Collaborative interoperation method and system for double-screen equipment
CN121070299A
