Closed arup-b closed 3 years ago
Dear Support Providers,
We have finally sorted out this issue. The File Transfer plugin can now be accessed at the Provider where the actual download happens.
What is missing is a CLEAR & DETAILED documentation of ionic native wrapper detailing how to instantiate and use the Native Plugins. I won't call it a bug - but blurry documentation is just a trap for developers.
I am refraining from posting the solution here - because - a recent Tweet attracted my attention where it was mentioned if developers would wish to get more help in lieu of a subscription. The irony is - we had to invest 3 valuable weeks to make the app run successfully on iOS as the documentation is not adequate.
Thanks.
@DevlprArup - I am glad to hear you got that sorted out.
For the documentation bit, my suggestion is to use the "Improve this doc" link and submit a PR with the improvements or clarifications that you would like to see in the document. A large component of any open source project is community support, and if you could contribute to that via needed clarifications to the documentation, that would be really great. If you don't feel comfortable doing that, that's cool too.
@kensodemann Yes .. I do agree with you. And I trust that should be a developer's TRUE SPIRIT.
I actually sent a direct Tweet to a Boss of the Ionic - seeking help on the issue -- I never received a single word as a response - instead saw a Tweet from the boss proposing subscription based help.
It hurts and I AM HURT.
@DevlprArup we are doing our best, but I hope you understand that it's just not possible for a team of ~30 to provide one-on-one support on a free basis to millions of Ionic developers. Also, I cannot respond to every tweet nor have I ever set that expectation.
We can help best through community channels, and in a way that allows others to see the solution when they encounter it again in the future.
That's how we can best balance improving the software (which is an incredible challenge), and also help those using it.
@mlynch Thanks for responding on my issue.
When I sent a direct tweet to you - I was in extreme confusion with the code and the issue. I failed to meet the deadline - and was utterly clueless. I felt like clutching the last straw when the sea was closing on me. And the proposal of subscription based help just thawed me.
Let's get back to the code :
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);
.....
....
What I presume is - [ I may be wrong.. please rectify if needed ]
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
3: 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
Any suggestion is welcome.
I consider that the "documentation" should not be referred to as "documentation" but more a taster of what might possibly function if you spend a good few days beating on it and searching on stackoverflow etc. On a number of occasions I have had replies from staff intimating how proud they were of the doco. When I supplied examples of where the doco was wrong or missing, answer came there none. I have to grit my teeth and allocate a day or so each time I try to use a new native feature - none has ever worked as documented. I appreciate the work put into creating a potentially valuable product, but the lack of attention to the doco must put off miriad developers. I wonder myself why I am still hanging in there.
This exact issue is happening to me as well when I try to use FileTransfer to upload an image to my server. It only effects builds on iOS, but works using Ionic Dev App on an iOS device, which makes it even more confusing.
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.
Current behavior:
As we tap a button that invokes the
fileTransfer.download(..)
method - the app halts to perform without throwing any Error.Console Output
I would like to draw attention at the following lines -
1:
The above is the result of the
console.log()
we placed inside theplatform.ready()
function as follows:The
console.log(JSON.stringify(this.fileTransfer));
at least prints an object with some properties.2: Now, we placed the same two lines of
console.log()
in the provider where the download operation code resides. The output printed on the console is surprisingly different as follows:The second line of
console.log()
just prints an object literal ( EMPTY OBJECT !!! ??? )And at this point - the app stops without throwing further Error and the download never completes.
As a side note, I would mention that the Android Version of the finished app already been released on Google Play and working fine with all its features.
Plugin List As we run
ionic cordova plugin list
we get the following output on the console window:Related code:
The actual download function is as follows:
Other information:
Ionic info: output is as follows:
Any help ??