0

We are developing an app which uses Native File Transfer plugin. But due to a weird issue we can not create the Test Flight / Release Build for iOS.

Issue: Even after successful installation of the 'File Transfer' plugin we see the following error while running the app with

ionic cordova run ios -lc

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

As we tap a button that invokes the fileTransfer.download(..) method - the app halts to perform without throwing any Error.

I have created a detailed post with logs and code at:

https://github.com/ionic-team/ionic-native/issues/2110

Any help ??

3 Answers3

2

After a thorough brainstorming I found the answer -

My issue was that the FileTransfer object could be accessed from inside the platform ready function but not inside a provider - this too on iOS [ Android version is working correctly ]

Here is what I did:

As I need an instance of the FileTransfer inside the provider - I created a variable - and an updater method -

private fileTransfer: any;

public setFileTransferRef( param ){
   this.fileTransfer = param;
}

And as I could access the FileTransfer inside the platform.ready() - I instantiated the FileTransferObject right there and updated the provider as follows -

initializeApp() {
    this.platform.ready().then(() => {
        console.log('fileTransfer: ');   
        console.log(JSON.stringify(this.fileTransfer));
        //
        let fileTransfer: FileTransferObject = this.fileTransfer.create();
        //
        this.mediaIOSProv.setFileTransferRef(fileTransfer);
        .....
        ....
  • Where mediaIOSProv is the Provider responsible to download the zip.

I also placed with the cordova.js inclusion after build/vendor.js in the index.html - ( I came across some posts where developers reported that doing so solved their missing plugin issue ) - Though there is no such official documentation.

<body>

  <!-- Ionic's root component and where the app will load -->
  <ion-app></ion-app>

  <!-- The polyfills js is generated during the build process -->
  <script src="build/polyfills.js"></script>

  <!-- The vendor js is generated during the build process
       It contains all of the dependencies in node_modules -->
  <script src="build/vendor.js"></script>

  <!-- cordova.js required for cordova apps -->
  <script src="cordova.js"></script>

  <!-- The main bundle js is generated during the build process -->
  <script src="build/main.js"></script>

</body>

Since the app successfully ran on iOS - I did not dare to change the placement of cordova.js

What I presume is -

1: It would be best to create a Provider to store references of each Native Plugin instantiated within the platform ready - and use the references as and when needed

2: There might be some information missing, specially regarding iOS, about the Ionic-Native Wrapper

Any suggestion / discussion will be highly appreciated.

0

Use this: Run ionic cordova platform add [platform] then ionic cordova build [platform] and run in your device. It worked for me!

zeitnot
  • 1,304
  • 12
  • 28
0

Remove the platform

  1. ionic cordova platform rm android

And then add the Platform again

  1. ionic cordova platform add android
karthik mano
  • 111
  • 1
  • 5