FileTransfer plugin but it's not installed IOS

I commented that I am developing an application in IONIC 3 and I am working with the native file transfer library. At the moment of wanting to download a file in IOS it does not execute it, not so when it is installed or debugged in android. According to the ionic documentation I am implementing it correctly and I do not understand why or what is missing so that IOS can execute the transfer.download which is the instruction that is not executed and by console I get the following error:

console.warn: 'Native: tried accessing the FileTransfer plugin but it’s not installed.

Below I leave my code:

import { FileTransfer, FileTransferObject } from ‘@ionic-native/file-transfer’;
import { File } from ‘@ionic-native/file’;
import { LoadingController } from ‘ionic-angular’;
declare var cordova: any;
@IonicPage()
@Component({
selector: ‘page-liquidaciones’,
templateUrl: ‘liquidaciones.html’,
})
export class LiquidacionesPage {
formLiquidaciones: FormGroup;
public txtCorreoLiquidacion;
rutUsuario: any;
resultado: any;
liquidaciones: any;
liquidacionesSeleccionadas:any={};
loading: any;
storageDirectory: string = ‘’;
//private fileTransfer: FileTransferObject;
//private localPath = ‘’;
private fileTransfer: any;
constructor(public navCtrl: NavController,
public navParams: NavParams,
private alertCtrl: AlertController,
public formBuilder: FormBuilder,
public kiberKiberpro: KibernumKiberproProvider,
public databaseService: DatabaseServiceProvider,
private transfer: FileTransfer,
private file:File,
private androidPermissions: AndroidPermissions,
public loadingController: LoadingController,
public platform: Platform
){
this.formLiquidaciones = this.formBuilder.group({
txtCorreoLiquidacion: [‘’, Validators.required]
});
this.platform.ready().then(() => {
if(!this.platform.is(‘cordova’)) {
return false;
}
if (this.platform.is(‘ios’)) {
//this.storageDirectory = this.file.dataDirectory;
this.storageDirectory = cordova.file.dataDirectory;
}
else if(this.platform.is(‘android’)) {
this.storageDirectory = cordova.file.externalRootDirectory + ‘/Download/’;
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 {
return false;
}
});
this.databaseService.getSesion(2).then(result => {
this.rutUsuario = result.valor;
})
.catch( error => {
});
}
DescargarLiquidaciones(){
this.loading = this.loadingController.create({ content: “Descargando Liquidacion(es)…” });
const fileTransfer: FileTransferObject = this.transfer.create();
var enviarLiquidaciones = ;
for(var i in this.liquidacionesSeleccionadas) {
if(this.liquidacionesSeleccionadas[i]) {
enviarLiquidaciones.push(i);
}
}
if(enviarLiquidaciones.length == 0)
{
this.alerta(“Debe seleccionar por lo menos una liquidación para que sea descargada.”);
}
else
{
//this.loading.present();
this.txtCorreoLiquidacion = ‘’;
this.kiberKiberpro.DescargarEnviarLiquidaciones(this.rutUsuario,enviarLiquidaciones, this.txtCorreoLiquidacion).then((res) => {
this.resultado = res;
var respuesta = JSON.parse(this.resultado.data);
let datos: string = JWT(this.resultado.data);
if(respuesta.status == “200”) {
let autorizacion = this.resultado.headers;
let nombreArchivo = datos.split(“tmp/”);
let urlFinal = datos;
this.platform.ready().then(() => {
fileTransfer.download(urlFinal , this.storageDirectory + nombreArchivo[1]).then((entry) => {
console.log(“INGRESA FILE TRANSFER”);
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();
});
});
}
else if (respuesta.status == “201”){
this.alerta(“Hubo un problema con el envío de la(s) liquidacion(es) al correo ingresado. Si el problema persiste favor contactarse al 816 35 12 o 816 35 09”);
this.loading.dismissAll();
let autorizacion = this.resultado.headers;
this.databaseService.GuardaSQLlite(1, autorizacion.authorization);
}
else if (respuesta.status == “401”){
this.alerta(“Token no válido.”);
this.loading.dismissAll();
}
else{
this.alerta(“Hubo un problema inesperado, Favor intente nuevamente. Si el problema persiste favor contactarse al 816 35 12 o 816 35 09”);
this.loading.dismissAll();
}
}, (err) => {
this.alerta(“Ha ocurrido un problema, intente nuevamente por favor. Si el error persiste pongase en contacto con el area de soporte.”);
this.loading.dismissAll();
});
}
}

My output ionic information
Ionic:

ionic (Ionic CLI) : 4.1.2 (/usr/local/lib/node_modules/ionic) Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.1.10

Cordova:

cordova (Cordova CLI) : 8.1.1 (cordova-lib@8.1.0) Cordova Platforms : ios 4.5.4 Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 6 other plugins)

System:

ios-deploy : 2.0.0 NodeJS : v8.12.0 (/usr/local/bin/node) npm : 6.4.1 OS : macOS Xcode : Xcode 9.4 Build version 9F1027a

I remain attentive to your answers and I thank you in advance for your help and opinions

Do you have cordova-plugin-file-transfer installed?

1 Like

Thank you for your answer, as download the sources and just enter the npm install commands do not add the library because in the github repository the xml file is not uploaded, therefore, you have to install all the libraries that the application needs. they can close the topic and the help is appreciated

1 Like