|
- // 显示是否更新对话框
- function showUpdateConfirm() {
- var confirmPopup = $ionicPopup.confirm({
- title: '版本升级',
- template: '1.更新1;</br>2.更新2;</br>3.更新3;</br>4.更新4', //从服务端获取更新的内容
- cancelText: '取消',
- okText: '升级'
- });
- confirmPopup.then(function (res) {
- if (res) {
- $ionicLoading.show({
- template: "已经下载:0%"
- });
- var url = encodeURI(ENV.serverAppURL);//可以从服务端获取更新APP的路径
- var targetPath = ENV.localSaveAppURL; //APP下载存放的路径,可以使用cordova file插件进行相关配置
- var trustHosts = true;
- var options = {};
- var fileTransfer = new FileTransfer();
- fileTransfer.onprogress = function(progressEvent) {
- //进度,这里使用文字显示下载百分比
- $timeout(function () {
- var downloadProgress = (progressEvent.loaded / progressEvent.total) * 100;
- $ionicLoading.show({
- template: "已经下载:" + Math.floor(downloadProgress) + "%"
- });
- if (downloadProgress > 99) {
- $ionicLoading.hide();
- }
- })
- };
- fileTransfer.download(url,targetPath,
- function(entry){
- // 打开下载下来的APP
- $cordovaFileOpener2.open(targetPath, 'application/vnd.android.package-archive')
复制代码 我使用http://bbs.phonegap100.com/thread-2046-1-1.html中的例子,但没用,看了https://github.com/apache/cordova-plugin-file-transfer,把$cordovaFileTransfer改成了var fileTransfer = new FileTransfer(),也不见效。有研究过的大神吗?怎么用啊? |
|