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.