Ionic Download APK upgrade app

Source: Internet
Author: User

Upgrade the app through the update file, if encountered such as update plug-ins and other issues, the previous article is not resolved, so in order to solve this problem, you need to download APK file upgrade app.

1. The configuration file is as follows: {' appversion ': ' 1.0.0 ', ' content ': ' 1. Update the app info show <br>2. Fix xxx '}

2. Installing Ngcordova,:https://github.com/driftyco/ng-cordova

      1. Copy the Ng-cordova.js to your Lib folder, and then introduce the Cordova.js file in the index.html file, as
             <!---             <src= "Lib/ngcordova/ng-cordova.js"  ></script>             <src= " Cordova.js "></script>

2. Then inject into your module, such as App.js, such as:

Angular.module (' starter ', [' Ionic ', ' Ngcordova ']);

3. Then download the plugin needed to transfer the file

File Managementcordova plugin add cordova-plugin-file  

File transfercordova plugin add cordova-plugin-file-transfer

App version Cordova-plugin-app-version

File Open Cordova-plugin-file-opener2

First, by comparing the app version number to the server profile version number, if it is inconsistent, upgrade. Get version after background and update content

     service.checkupdate=function() {           appversion.getversion (). Success (function( Data) {                $cordovaAppVersion. GetVersionNumber (). Then (version) {                    if (version!=data.appversion) {                         service.showupdateconfirm (data.content);}})           })       }

Then, if the version number is inconsistent, the popup prompts the user whether to upgrade.

service.showupdateconfirm=function(content) {varConfirmpopup =$ionicPopup. Confirm ({ --popup window prompts to upgrade title:' Version upgrade ', Template:content,Canceltext: ' Cancel ', Oktext:Upgrade               }); Confirmpopup.then (function(res) {if(res) {$ionicLoading. Show ({Template:"Downloaded: 0%"--Hint progress bar                      }); varurl = "http://xxxx.com/xxxx.apk"; --Server file address varTargetPath = cordova.file.externaldatadirectory+ "xxx.apk"; --Mobile download location, can be set according to Cordova file varTrusthosts =true                      varOptions = {}; $cordovaFileTransfer. Download (url,targetpath,options,trusthosts). Then (function(Result) {$cordovaFileOpener 2.open (TargetPath,' Application/vnd.android.package-archive '). Then (function(){
},function() {}) $ionicLoading. Hide (); },function(ERR) {alert (ERR); },function(Progress) {$timeout (function(){ varDownloadProgress = (progress.loaded/progress.total) * 100; $ionicLoading. Show ({Template:"Downloaded:" + math.floor (downloadprogress) + "%" }); if(DownloadProgress > 99{$ionicLoading. Hide (); } }) }); }Else{ } }) }

4. At this point, the apk will download the phone, automatically open the installation, upgrade completed. The upgrade can be used together with the previous article, the small update with the above, the big update with this article.

Ionic Download APK upgrade app

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.