Application upgrade Introduction: application upgrade

Source: Internet
Author: User

Application upgrade Introduction: application upgrade

The Do platform application upgrade includes two methods: one is the most common installation package upgrade and the other is the intra-application upgrade. Obviously, the second upgrade method is more flexible.

Application installation package upgrade

This is the common Upgrade Method for native applications. For example, the android installation package is an apk file, and the ios installation package is an ipa file. If you want to upgrade, you can only download a new apk/ipa file, and then install and overwrite the old version. The basic process is as follows:

  1. Call do_Global.getVersion () to check the current application version.
  2. Send a GET/POST request via do_Http to upgrade the server and request the latest version number of the current application. The server is built by the developer and has nothing to Do with the Do platform.
  3. Compare the two versions. If they are different, call the do_External.openURL () method and use the browser in the operating system to open the webpage for downloading the application. Download and install the new application on the Web page to overwrite the old one.

Note the following:

In-application upgrade

The in-app upgrade is not a specific function of the Do platform, but it is very convenient to use the in-app upgrade. In-app upgrades can be understood as incremental upgrades, replacing any project files.

  1. Check the version number of the current application. The version number may be read from the file or from the SQLite database. The user determines whether to read or write this version.
  2. Send a GET/POST request via do_Http to upgrade the server and request the latest version number of the current application. This version number refers to the version number of the source code in the application. The server is built by the developer and has nothing to Do with the Do platform, the maintenance of the version number is also determined by the developer.
  3. Compare the two versions. If they are different, call the do_Http.download method to download the upgrade package, which is usually a zip file.
  4. After the download, decompress the zip file to the data: // directory
  5. Use the update method of do_App to copy all the latest files to the corresponding directory under source: // to overwrite the old files. And update the new version to the file or database.

Note the following:

Refer to an example Demo. The main source code is as follows:

Var button = ui ("do_Button_1"); button. on ("touch", function () {upgrade () ;}); function upgrade () {// get the current application version var current_version = storage. readFileSync ("data: // version.txt"); // obtain the latest version number of the server and download the upgrade. // because no real upgrade service is set up, so comment out this line and directly call the update method // getLatestVersion (current_version); update ("1.1", "data: // update.zip ");} // obtain the latest version number from the server. function getLatestVersion (ver) {var http = mm ("do_Http"); http. method = "GET"; http. url = "http://www.xxxx.com/getLatestVersion? Current = "+ ver; http. on ("success", function (d) {// when the server determines that the latest version is not equal to the current version, it returns the latest version and otherwise returns NULL if (d) {// start to download the latest zip download (d);} else nf. alert ("the current version is the latest version") ;}); http. request () ;}// obtain the latest update package from the server function download (d) {var http = mm ("do_Http"); var zip = "data: // update.zip "; http. method = "POST"; // d. downlaodURL is the zip download url, d. version is the latest version http. url = d. downloadURL; http. on ("success", function (d) {update (d. version, zip) ;}); http. download (zip);} // decompress the package, overwrite the old file, and update the local version number function update (ver, zip) {storage. unzip (zip, "data: // update", function (data) {// you can copy an object or a directory app. update (["data: // update/test. ui "," data: // update/test. ui. js "]," source: // view ", function () {nf. alert ("upgrade completed"); storage. writeFile ("data: // version.txt", "1.1", function () {app. closePage ();});});})}

For download of this example, refer to here

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.