We want to try using cordova-plugin-file-transfer. I’m just not sure how to install it. Most answers I find explain using commands like this:
ionic cordova plugin add
But we’ve never (had to) install the ionic CLI. We’ve just purely used capacitor plugin & the capacitor CLI so far. I don’t know enough about ionic to understand if I can just install the ionic CLI to add a cordova plugin in my capacitor project, or if it requires more configutation changes to use some ionic features.
Can someone clarify?
Same question for using ionic plugins really
In Capacitor you install plugins (both Capacitor and Cordova) using npm install.
npm install cordova-plugin-file-transfer.
You will probably have build problems because latest released version of the plugin is very out of date and uses now deprecated (and removed) class names, so it’s better if you install the plugin from github directly with
npm install https://github.com/apache/cordova-plugin-file-transfer, as those problems I mention are fixed, but not released.
@julio-ionic, thanks! So just npm install and we can use them. And then in this case the global
FileTransfer object should become available on ios and android builds? And for typescript support I guess we can make our own declarations if they don’t exists? I’ll try installing through github!
Yeah, the global
FileTransfer object should be available once you install the plugin and do a
npx cap sync (so it copies the plugin files to the proper places).
/// <reference types="cordova-plugin-file-transfer" />
There is also this awesome-cordova-plugins project that is a set of typescript wrappers around cordova plugins that you can import for easier usage, but they were created with angular in mind, while you can use them without angular it’s also a bit complex.