Native: tried accessing the FileTransfer plugin but it's not installed

Hi,
I have a problem with the Ionic Native FileTransfer Plugin. I want to use it to download Images from a server. I have installed everything a is it mentioned in the docs. But when I run it on my ios Simulator, it comes a warning that it is not installed.

I am not reaching this part of the code. I neither get the “download complete” nor the “error” message on the console.

const fileTransfer: FileTransferObject = this.transfer.create();
fileTransfer.download(url, this.file.dataDirectory + item.title).then((entry) => {
                                  console.log('download complete: ' + entry.toURL());
                                }, (error) => {
                                  console.log("error");
                                })

Here you can see the console output from my ios Simulator.

And here you can see, that the plugin is installed.

Do I have to install it separately for my ios Simulator?

I am using ionic 3.8.1 on a Mac with macOS Sierra.

2 Likes

Do you see it when you type cordova plugin in the command line?

Where exactly did you place the code you posted?
What is your ionic info output?

This is my ionic info output:

41

does it matter, where I use this code?

I probably wouldn’t ask for it if it wouldn’t, would I?

My guess: You are running this code before the platform is ready.

1 Like

yes.

36

indeed I did. After you said, that it does matter where I use the code, I found out that I call the function in the constructor of app component. I changed it to:

initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      this.dataService.checkLastUpdate();
    });
  }

And now it works. Thanks for the hint!

2 Likes