The practice of Ionic hot Update plugin Cordova-hot-code-push

Source: Internet
Author: User
Tags hash json


Recently in the hybrid app, want to use hot new technology, that is, users do not have to reinstall the client, you can silently or prompt users to update the inside HTML JS CSS img and other files, like pay Treasure Festival, double 11 for the icon, are the use of hot update.
Http://www.ionic.wang/article-index-id-71.html (This is Ionic's brief introduction to this hot update plugin) 


1. Installing Plugins



Perform the operation on the basis of completing the Ionic Basic Development environment first install the CORDOVA-HOT-CODE-PUSH-CLI


NPM install-g CORDOVA-HOT-CODE-PUSH-CLI


Note: If an installation error occurs during this step, the following methods can be used to resolve


A, install python2.7, and add C:\Python27 to environment variable
B, install Vs2013_rtm_dskexp_chs


I bon voyage in this step, there is no mistake, because my computer has these things, look on the internet a lot of people will be in this step out of the problem so special reminder. Install Cordova-hot-code-push-plugin in the app directory


Cordova Plugin Add cordova-hot-code-push-plugin
Cordova plugin Add Cordova-hot-code-push-local-dev-addon


2. Use the plugin to confirm that the installation is complete and run CORDOVA-HCP build
After running the WWW folder, Chcp.json and chcp.manifest two files appear
A, Chcp.json file content description


{
  "autogenerated": True,
  "release": "2016.08.29-15.52.14",  //version number
  "Content_url": "// 1.1.1.1:80/www/",//www folder where the remote address
  " Update ":" Now "//in   three cases
                    //Start-app Install the update at startup. Default value.
                    Resume-app Install updates when switching from the background.
                    Now-web content is downloaded to install the update.
}


The file is automatically regenerated each time the CORDOVA-HCP build is run



B, chcp.manifest as a list of documents
Content is the HTML js CSS img Files such as the path and hash value, each time the file is modified to run CORDOVA-HCP build corresponding modified file hash value will be updated.



C, there is a file in the diagram. chcpenv
Content is the server address where updates are stored


{
  "Content_url": "http://1.1.0.1:80",
  "Config_url": "Http://1.1.0.1:80/chcp.json"
}

3. Test Run

After you've packaged the build app to build the app, change the app page content, then run CORDOVA-HCP build to generate the latest configuration, Copy all files in the entire WWW directory (including Chcp.json and chcp.manifest two files) to the remote address configured in Chcp.json

Re-open the app (remember to open it two times before you see the effect) and see what you've just updated.



Note: Be sure to note the steps, because the app side must be different from the server, the Chcp.json format is consistent, the version number must not be the same, there is the Chcp.manifest file in the modified file hash value is also different, Of course, the plug-in is not a problem, generally not error


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.