Android で試してみましたが、IOS でも動作することを願っています。
enter code here
function fun(){
var dfd = $.Deferred(function (dfd){
var remoteFile = "Your link";
var localFileName = remoteFile.substring(remoteFile.lastIndexOf('/')+1);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getFile(localFileName, {create: true, exclusive: false},
function(fileEntry) {
var localPath = fileEntry.fullPath;
if (device.platform === "Android" && localPath.indexOf("file://") === 0) {
localPath = localPath.substring(7);
}// You need to write IOS instead of Android
var ft = new FileTransfer();
ft.download(remoteFile, localPath, function(entry) {
dfd.resolve('file downloaded');
// Do what you want with successful file downloaded and then
// call the method again to get the next file
//downloadFile();
}, fail);
}, fail);
}, fail);
});
return dfd.promise();
}
fun().then(function(msg){
if(msg==="file downloaded")
{
alert("Download complete");
}
else
{
alert("Download error")
}
});
function fail(){
alert("error");
}