Logic hot update method implemented based on Webview of Android and iOS system

By using Webview to achieve logical hot updates in Android and iOS systems, the problems of high development costs, poor stability, high maintenance costs and inability to cross-platform in the existing technology are solved, and an efficient, reliable and secure cross-platform hot update solution is realized.

CN119645459APending Publication Date: 2025-03-18BEIYIN FINANCIAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411771228.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

The existing Android hot update technology has problems such as high development costs, poor stability, high maintenance costs and inability to cross-platform, making it difficult to achieve a reliable and safe hot update solution.

Method used

The logical hot update method based on the Android and iOS system Webview is adopted to realize cross-platform logical hot updates by implementing rich client plug-in capabilities, customizing WebView components, rewriting WebViewClient and WebChromeClient, and realizing local cache and online updates of JavaScript scripts.

Benefits of technology

It reduces development costs, improves system stability, reduces maintenance costs, and realizes cross-platform hot update capabilities, improving user experience and application update efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645459A_ABST
    Figure CN119645459A_ABST
Patent Text Reader

Abstract

The invention discloses a logic hot updating method based on Android and iOS system Webview implementation. The updating method comprises the steps that Android platform implementation and iOS platform implementation are carried out; the implementation of the Android platform comprises the following steps of: realizing rich client plug-in capability, which is used for carrying out logic interaction on a native code and a JavaScript code; customizing a WebView component and injecting the WebView component into the client plug-in; a WebViewClient and a WebChromeClient are rewritten, and the WebViewClient and the The local caching and the online updating of the JavaScript script are realized; the realization of the iOS platform comprises the following steps of: realizing rich client plug-in capability for logic interaction between a native code and a JavaScript code; a WKWebView is used in the method; the communication between the JavaScript and the Objective-C is realized; the method comprises the following steps of: calling JavaScript by Objective-C (Objective-C); and local caching and online updating of the JavaScript script are realized. Rich client plug-in capability is realized, and the method is used for logic interaction between native codes and JavaScript codes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of application update of Android system, and in particular to a logic hot update method based on Android and iOS system Webview. Background Art

[0002] With the rapid development of mobile Internet, the frequency of application updates on the Android system is increasing. The traditional way to update applications is to submit a new version of the application to the application store for review, and users download and install the new version to update functions or fix known bugs. However, this method has many inconveniences. It not only consumes time and traffic, but also frequent version updates may cause user dissatisfaction, especially when urgent repairs of serious bugs, the entire process of repackaging, testing, submitting for review, and user downloading and installation takes a long time, and the user experience is poor.

[0003] To solve the above problems, Android hot update technology came into being. Hot update refers to the act of updating software data manually or automatically in the application without going through the software version update review of the application store. Hot update technology allows developers to dynamically update the functions and content of the application and fix program bugs without disturbing users, greatly improving the efficiency of application updates and user experience.

[0004] However, the Android system has certain restrictions and security considerations on code hot updates, which makes it challenging to implement a reliable and secure hot update solution. At the same time, different application scenarios and needs also put forward diverse requirements for hot update technology.

[0005] The disadvantages of the prior art are:

[0006] Plugin technology, class replacement and patching solutions, and loading solutions based on custom ClassLoader can all achieve hot updates to varying degrees, but all have the following common disadvantages:

[0007] High development cost

[0008] The above existing hot update technologies involve relatively complex class loading mechanisms, resource loading and other issues, requiring developers to have a deep understanding of these mechanisms and have the corresponding technical strength to effectively implement and apply plug-in technology. Equipping high-level developers will increase project costs.

[0009] Poor stability

[0010] The above hot update technology usually relies on underlying mechanisms such as reflection, and tampers with system private methods to achieve hot updates, which may affect the stability of the application. Especially in operating systems such as Android, as the system version is updated, the restrictions on API calls and security requirements are also constantly increasing, which may increase the risk of plug-in technology implementation, resulting in the hot update mechanism not being effective on the new Android system, and even causing the APP to fail to run normally.

[0011] The maintenance cost is high. As the number and versions of hot update packages increase, the relationship between the plug-in and the main APP becomes increasingly complicated, and the maintenance cost will also increase accordingly.

[0012] It is not cross-platform, and the hot update technology is only applicable to applications under the Android system and does not support the iOS system. Summary of the invention

[0013] In view of the above problems, the present invention is proposed to provide a logic hot update method based on Android and iOS system Webview implementation to overcome the above problems or at least partially solve the above problems.

[0014] According to one aspect of the present invention, a logic hot update method based on Android and iOS system Webview is provided, and the update method includes: Android platform implementation and iOS platform implementation;

[0015] The Android platform implementation includes:

[0016] Implement rich client plug-in capabilities for logical interaction between native code and JavaScript code;

[0017] Customize the WebView component and inject the above client plug-in;

[0018] Rewrite WebViewClient and WebChromeClient;

[0019] Implement local caching and online updates of JavaScript scripts;

[0020] The iOS platform implementation includes:

[0021] Implement rich client plug-in capabilities for logical interaction between native code and JavaScript code;

[0022] Use WKWebView;

[0023] Implement communication between JavaScript and Objective-C;

[0024] Implement Objective-C calling JavaScript;

[0025] Implement local caching and online updating of JavaScript scripts.

[0026] Optionally, the implementation of rich client plug-in capabilities for logical interaction between native code and JavaScript code specifically includes:

[0027] Use Android native code to implement native plug-in capabilities for network communication, local storage, software-hardware interaction, native UI interaction, system capability interaction, business logic interaction, and interaction between applications, making up for the problem of single JavaScript scripting capabilities.

[0028] Optionally, the custom WebView component injecting the above client plug-in specifically includes:

[0029] Create a custom WebView component class that inherits from WebView.

[0030] In this custom class, the Java object is injected into the JavaScript environment of WebView through the addJavascriptInterface method;

[0031] The Java object includes native methods that need to be exposed to JavaScript calls.

[0032] Optionally, rewriting WebViewClient and WebChromeClient includes:

[0033] Rewrite the shouldOverrideUrlLoading and onPageFinished methods of WebViewClient to handle WebView's loading request and page loading completion events;

[0034] Rewrite the onReceivedTitle and onJsAlert methods of WebChromeClient to handle the title reception and JavaScript warning events of WebView.

[0035] Optionally, the implementation of local caching and online updating of JavaScript scripts specifically includes:

[0036] Use the shouldInterceptRequest method to intercept network requests issued by WebView;

[0037] Determine whether the requested resource is a JavaScript script. If so, first check whether there is a local cache;

[0038] If there is a local cache and the cache has not expired, the local cached resource is returned directly;

[0039] If there is no local cache or the cache has expired, the resource is downloaded from the server, the data is stored locally, and then returned to the WebView for loading.

[0040] Optionally, the implementation of rich client plug-in capabilities for logical interaction between native code and JavaScript code specifically includes:

[0041] Use iOS native code to implement native plug-in capabilities for network communication, local storage, software-hardware interaction, native UI interaction, system capability interaction, business logic interaction, and interaction between applications, making up for the problem of single JavaScript scripting capabilities.

[0042] Optionally, the use of WKWebView specifically includes:

[0043] Create a WKWebView instance as a web page display component;

[0044] Use WKWebViewConfiguration to configure WebView.

[0045] Optionally, the implementation of communication between JavaScript and Objective-C specifically includes:

[0046] Use the WKScriptMessageHandler protocol to implement Objective-C's reception and processing of JavaScript messages;

[0047] Register the Objective-C object as the receiver of JavaScript messages through the addScriptMessageHandler method of WKUserContentController;

[0048] In JavaScript, send messages to Objective-C through the webkit.messageHandlers.alias.postMessage method.

[0049] Optionally, the implementation of calling JavaScript from Objective-C specifically includes:

[0050] Use WKWebView's evaluateJavaScript:completionHandle: method to execute JavaScript code;

[0051] Process the results of JavaScript execution in completionHandler.

[0052] Optionally, the implementation of local caching and online updating of JavaScript scripts specifically includes:

[0053] Use NSURLProtocol subclass to intercept network requests issued by WebView;

[0054] Determine whether the requested resource is a JavaScript script. If so, first check whether there is a local cache. If there is a local cache and the cache has not expired, return the local cached resource data through the dataTaskWithRequest method of NSURLSession.

[0055] If there is no local cache or the cache has expired, the resource is downloaded from the server through NSURLSession, stored locally, and then returned to WebView for loading.

[0056] The present invention provides a logic hot update method based on Android and iOS system Webview implementation, the update method includes: Android platform implementation and iOS platform implementation; the Android platform implementation includes: realizing rich client plug-in capabilities for logical interaction between native code and JavaScript code; customizing WebView components and injecting the above client plug-ins; rewriting WebViewClient and WebChromeClient; realizing local caching and online updating of JavaScript scripts; the iOS platform implementation includes: realizing rich client plug-in capabilities for logical interaction between native code and JavaScript code; using WKWebView; realizing communication between JavaScript and Objective-C; realizing Objective-C calling JavaScript; realizing local caching and online updating of JavaScript scripts. Realizing rich client plug-in capabilities for logical interaction between native code and JavaScript code.

[0057] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0059] Figure 1 A flowchart of a logic hot update method implemented based on Android and iOS system Webview is provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0060] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0061] The terms "comprises" and "having" and any variations thereof in the description embodiments, claims and drawings of the present invention are intended to cover non-exclusive inclusions, for example, including a series of steps or units.

[0062] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0063] like Figure 1 As shown, a logic hot update method based on Android and iOS system Webview implementation includes:

[0064] 1. Android platform implementation

[0065] a. Implement rich client plug-in capabilities for logical interaction between native code and JavaScript code;

[0066] Use Android native code to implement rich native plug-in capabilities such as network communication, local storage, software-hardware interaction, native UI interaction, system capability interaction, business logic interaction, and interaction between applications, to make up for the problem of single JavaScript scripting capabilities.

[0067] b. Customize the WebView component and inject the above client plug-in

[0068] Create a custom WebView component class that inherits from WebView.

[0069] In this custom class, the Java object is injected into the JavaScript environment of WebView through the addJavascriptInterface method. The Java object includes: native methods that need to be exposed to JavaScript calls.

[0070] c. Rewrite WebViewClient and WebChromeClient

[0071] Rewrite the shouldOverrideUrlLoading and onPageFinished methods of WebViewClient to handle the loading request and page loading completion events of WebView.

[0072] Rewrite the onReceivedTitle and onJsAlert methods of WebChromeClient to handle events such as WebView's title reception and JavaScript warnings.

[0073] d. Implement local caching and online updates of JavaScript scripts

[0074] Use the shouldInterceptRequest method to intercept network requests issued by WebView.

[0075] Determine whether the requested resource is a JavaScript script. If so, first check whether there is a local cache.

[0076] If there is a local cache and the cache has not expired (which can be determined by timestamp or version number), the local cached resource is returned directly.

[0077] If there is no local cache or the cache has expired, the resource is downloaded from the server, stored locally, and then returned to the WebView for loading.

[0078] 2. iOS platform implementation

[0079] a. Implement rich client plug-in capabilities for logical interaction between native code and JavaScript code. Use iOS native code to implement rich native plug-in capabilities such as network communication, local storage, software-hardware interaction, native UI interaction, system capability interaction, business logic interaction, and interaction between applications, to make up for the problem of single JavaScript scripting capabilities.

[0080] b. Using WKWebView

[0081] Create a WKWebView instance as a web page display component.

[0082] Use WKWebViewConfiguration to configure WebView, such as setting the content controller.

[0083] c. Implement communication between JavaScript and Objective-C

[0084] Use the WKScriptMessageHandler protocol to implement Objective-C's reception and processing of JavaScript messages.

[0085] Register the Objective-C object as the receiver of JavaScript messages through the addScriptMessageHandler method of WKUserContentController.

[0086] In JavaScript, send messages to Objective-C through the webkit.messageHandlers.alias.postMessage method.

[0087] d. Implement Objective-C to call JavaScript

[0088] Use the evaluateJavaScript:completionHandler: method of WKWebView to execute JavaScript code.

[0089] Process the results of JavaScript execution in completionHandler.

[0090] e. Implement local caching and online updates of JavaScript scripts

[0091] Use NSURLProtocol subclass to intercept network requests made by WebView.

[0092] Determine whether the requested resource is a JavaScript script. If so, first check whether there is a local cache.

[0093] If there is a local cache and the cache has not expired (which can be determined by timestamp or version number), the local cached resource data is returned through the dataTaskWithRequest method of NSURLSession.

[0094] If there is no local cache or the cache has expired, the resource is downloaded from the server through NSURLSession, stored locally, and then returned to WebView for loading.

[0095] Beneficial effects: 1. Realize rich client plug-in capabilities for logical interaction between native code and JavaScript code;

[0096] 2. Rewrite WebViewClient and WebChromeClient;

[0097] 3. Implement local caching and online updates of JavaScript scripts.

[0098] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A logic hot update method based on Android and iOS system Webview, characterized in that: The updating method includes: Android platform implementation and iOS platform implementation; The Android platform implementation includes: Implement rich client plug-in capabilities for logical interaction between native code and JavaScript code; Customize the WebView component and inject the above client plug-in; Rewrite WebViewClient and WebChromeClient; Implement local caching and online updates of JavaScript scripts; The iOS platform implementation includes: Implement rich client plug-in capabilities for logical interaction between native code and JavaScript code; Use WKWebView; Implement communication between JavaScript and Objective-C; Implement Objective-C calling JavaScript; Implement local caching and online updating of JavaScript scripts.

2. According to claim 1, a logic hot update method based on Android and iOS system Webview is characterized in that: The realization of rich client plug-in capabilities for logical interaction between native code and JavaScript code specifically includes: Use Android native code to implement native plug-in capabilities for network communication, local storage, software-hardware interaction, native UI interaction, system capability interaction, business logic interaction, and interaction between applications, making up for the problem of single JavaScript scripting capabilities.

3. According to claim 1, a logic hot update method based on Android and iOS system Webview is characterized in that: The custom WebView component, injecting the above client plug-in specifically includes: Create a custom WebView component class that inherits from WebView. In this custom class, the Java object is injected into the JavaScript environment of WebView through the addJavascriptInterface method; The Java object includes native methods that need to be exposed to JavaScript calls.

4. According to claim 1, a logic hot update method based on Android and iOS system Webview is characterized in that: The rewriting of WebViewClient and WebChromeClient includes: Rewrite the shouldOverrideUrlLoading and onPageFinished methods of WebViewClient to handle WebView's loading request and page loading completion events; Rewrite the onReceivedTitle and onJsAlert methods of WebChromeClient to handle the title reception and JavaScript warning events of WebView.

5. According to the method of logic hot update based on Android and iOS system Webview implementation in claim 1, it is characterized in that: The local caching and online updating of JavaScript scripts specifically include: Use the shouldInterceptRequest method to intercept network requests issued by WebView; Determine whether the requested resource is a JavaScript script. If so, first check whether there is a local cache; If there is a local cache and the cache has not expired, the local cached resource is returned directly; If there is no local cache or the cache has expired, the resource is downloaded from the server, the data is stored locally, and then returned to the WebView for loading.

6. According to the method of claim 1, the method is characterized in that: The realization of rich client plug-in capabilities for logical interaction between native code and JavaScript code specifically includes: Use iOS native code to implement native plug-in capabilities for network communication, local storage, software-hardware interaction, native UI interaction, system capability interaction, business logic interaction, and interaction between applications, making up for the problem of single JavaScript scripting capabilities.

7. According to claim 1, a logic hot update method based on Android and iOS system Webview is characterized in that: The use of WKWebView specifically includes: Create a WKWebView instance as a web page display component; Use WKWebViewConfiguration to configure WebView.

8. According to the method of claim 1, the method is characterized in that: The implementation of communication between JavaScript and Objective-C specifically includes: Use the WKScriptMessageHandler protocol to implement Objective-C's reception and processing of JavaScript messages; Register the Objective-C object as the receiver of JavaScript messages through the addScriptMessageHandler method of WKUserContentController; In JavaScript, send messages to Objective-C through the webkit.messageHandlers.alias.postMessage method.

9. According to the method of claim 1, the method is characterized in that: The implementation of Objective-C calling JavaScript specifically includes: Use WKWebView's evaluateJavaScript:completionHandler: method to execute JavaScript code; Process the results of JavaScript execution in completionHandler.

10. The method for implementing a logic hot update based on Android and iOS system Webview according to claim 1, characterized in that: The local caching and online updating of JavaScript scripts specifically include: Use NSURLProtocol subclass to intercept network requests issued by WebView; Determine whether the requested resource is a JavaScript script. If so, first check whether there is a local cache; If there is a local cache and the cache has not expired, the local cached resource data is returned through the dataTaskWithRequest method of NSURLSession; If there is no local cache or the cache has expired, the resource is downloaded from the server through NSURLSession, stored locally, and then returned to WebView for loading.