Method for upgrading H5 mixed development app

This article mainly introduces the method of upgrading H5 hybrid development app, the introduction is very detailed, with certain reference value, interested friends must have read!

Automatic upgrade: Generally, when the customer app opened the first time.

Manually upgrade: Provide an upgrade entry in the App interface.

Interface Effect Demonstration is as follows:

The code is actually very simple, but it is handled separately for iOS and Android. The basic idea is to get the APP version number of this unit, then compare the APP version number above the server if it is smaller than the APP version number above, then the update operation is performed. 升级H5混合开发app的方法

VAR BTN = [“Determine Upgrade”, “Cancel”]; // Get APP System Updates [Whether to Manually Click Get Update] Function AppUpdate (Ismanual) {Console.log (‘ Appupdate ‘); mui.plusready (function () {plus.Runtime.getProperty (Plus.Runtime.Appid, Function); console.log (‘ ver: ‘+ ve); var URL = Config.getAppVersion; var client; var ua = navigator.USERAGENT.TOLOWERCASE (); if (/iphone|ipad|ipod/.test (ua)) {// Apple phone mui.ajax ({TYPE: “get”, DataType: ‘JSON’, URL: “” ,// Get the current home AppStore version information DATA: {ID: 131812xxxx // App Unique ID}, contentType: ‘Application / X-www-form-urlencoded; charset = utf-8’, success: function (data) {console.log (‘data:’ + json.stringify (data); Var Resultcount = DATA.ResultCount; for (var i = 0; i

ver) {var _msg = “Discovery new version: v” + normitem; //plus.nativeui.alert (“Discover new version: v” + normitem) ; mui.confirm (_msg, ‘upgrade confirm “, btn, function (e) {IF (e.index == 0) {// execution upgrade operation Document.Location.href = ‘’; / / On the new appStore download address}}; return;}} if (ismanual) {mui.toast (‘The current version number is already the latest’);} return;}});} else if (/android/.test UA)) {mui.ajax (URL, {Data: {APKVERSION: VER,}, DataType: ‘JSON’, TYPE: ‘GET ‘, Timeout: 10000, Success: function (data) {//console.log (‘data:’4json.stringify (DATA)) IF (Data.Statuscode = 200 && Data.Data> Ver) {// MUI .toast (“Discover the new version: v” +; // Get a remote database in the new Andriod version number var _msg = “Discover the new version: v” +; mui.confirm (_msg, ‘upgrade Confirm ‘, BTN, Function (E) {if (e.index == 0) {// Perform an upgrade operation plus.nativeui.toast (“Preparing the environment, please wait!”); Var DTASK = Plus.downloader. CreateDownload (config.apkurl, {}, function (d, status) {if (status == 200) {Var path = D.FileName; // Download APK Plus.Runtime.install (// Automatically install APK file} else {plus.nativeui.alert (‘version update failed:’ + status);}}); DTASK .Start ();}};} else {console.log (‘The current version number is the latest’); if (ismanual) {mui.toast (‘The current version number is already the latest “);} return;}} , Error: Function (XHR,Type, ErrerthHrown) {if (ismanual) {mui.toast (‘network exception, please try again);}}});}});});}
   Our iOS app is published in Apple App Store, and Android app is deployed directly on our own server (such as the IIS server), because Android's application market is too much, then the upgraded version is A very troublesome thing, when you release a version, you have to go to all Android application market to submit an update.  
Need not to note that this method is used manually updated and automatically updated, it is necessary to pass different parameters because it is automatically updated, if the system detects the current version, then it will not be on the client To make a display, however, if it is already the latest version, it is necessary to prompt customers.

Automatic Update Call: AppUpdate (); // Detecting APP Update

Manually Update Call: AppUpdate (TRUE); // Detect APP Update

The above is upgraded H5 mixing All content of the development of AppAp, thank you! The content that wants to share is helpful to everyone, more related knowledge, welcome to pay attention to Tumi Yun Industry News Channel!

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment