1. 添加插件:cordova plugin add cordova-plugin-file-transfer
2. 调用方法:
var fileTransfer = new FileTransfer();
//下载地址;
var source="http://xxx/xxxx/ionic.apk";
var target="/sdcard/Download/ionic.apk";
var trustAllHosts = true;
var options = {};
function successCallback(entry){} ;
function errorCallback(error){};
fileTransfer.download(source,target,successCallback,errorCallback,trustAllHosts,options);
fileTransfer.onprogress = function(progressEvent){
if (progressEvent.lengthComputable){
$ionicLoading.show({
template: "已经下载:" +Math.floor((progressEvent.loaded / progressEvent.total)*100) + "%"
});
}
}