I have the following dilemma, I am working with Ionic 3 and I have a class that downloads a file from a URL that brings me a REST service. This download the file without problems but I have not known how to implement or I have not searched correctly to add a download notification as shown in the following link: ionic 2 show file download progress in notification
Inside the link there are 2 answers corresponding to how to add the library but I do not know if they are also compatible with IOS since I need them to be for android and IOS. I currently work with file.transfer to save the file on the device. I leave the code below:
Blockquote
this.platform.ready().then(() => {
this.databaseService.getSesion(2).then(result => {
this.rutUsuario = result.valor;
})
.catch( error => {
});
if (this.platform.is('ios')) {
this.storageDirectory = cordova.file.documentsDirectory;
}
else if(this.platform.is('android')) {
this.storageDirectory = cordova.file.externalRootDirectory + '/Download/';
/**
* Permisos de Android
*/
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE).then(
result => {
if (result.hasPermission) {
// code
} else {
this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE).then(result => {
if (result.hasPermission) {
// code
}
});
}
},
err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE)
);
}
else {
// exit otherwise, but you could add further types here e.g. Windows
return false;
}
});
}
if(respuesta.status == "200") {
let autorizacion = this.resultado.headers;
let nombreArchivo = datos.split("tmp/");
let urlFinal = datos;
fileTransfer.download(urlFinal , this.storageDirectory + nombreArchivo[1]).then((entry) => {
this.alerta("Se ha descargado el archivo de manera satisfactoria.");
this.loading.dismissAll();
this.databaseService.GuardaSQLlite(1, autorizacion.authorization);
this.navCtrl.setRoot(HomePage);
}, (error) => {
this.alerta("Hubo un error al momento de descargar el archivo. Si el problema persiste favor contactarse al 816 35 12 o 816 35 09.");
this.loading.dismissAll();
});
If someone had a website with an example of how it is implemented correctly I would appreciate it since I am somewhat blocked at this time and I can not find a solution.
The help given in advance is greatly appreciated