I have used the following code to download file:
$scope.onDownloadMusic = function( live ) {
var downloadUrl = offlineUrl + fileName;
var hostUrl = encodeURI(live.url);
var fileTransfer = new FileTransfer();
fileTransfer.download(
hostUrl,
downloadUrl,
function(entry) {
alert('Your download has completed.');
},
function(error) {
alert(error.source);
},
false,
{
headers: {
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
}
);
};
It works fine on Android. However, when I tried the same code on iOS, I always got an error.
I didn't know what went wrong. Any help is really appreciated.
I finally found the solution:
Simple trick which takes me quite some time to investigate:
var downloadUrl = encodeURI(cordova.file.dataDirectory + fileName);
var hostUrl = encodeURI(live.url);
What's interesting here is encodeURI.