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
-
- 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