我试过这个,它适用于Android手机。在iOS中,我可以显示“图像已下载”警报,但我在iPhone图像库中找不到该图像。
var path = 'http://example.com';
if( navigator.connection.type == Connection.NONE ) {
navigator.notification.alert('unable to download an image due to disconnect network.');
return;
} else {
var uri = encodeURI(path);
var fileName = path.split('/').pop();
var filePath = fileSystem.root.toURL() + fileName;
var fileTransfer = new FileTransfer();
fileTransfer.download(uri, filePath, function(entry){
navigator.notification.alert( 'The Image has been downloaded.')
});
}