I've been working through this example: https://capacitor.ionicframework.com/docs/basics/cordova
I've run:
npm install cordova-plugin-qrscanner
npx cap sync
and I can see the plugin installed in my node_modules.
What I do not know how to do is call one of the functions on the cordova-plugin. I'm wondering if I need a packager like webpack?
I'm also confused as to how this works if the cordova plugin contains native swift (or other) code.
This is why Capacitor is able to utilise Cordova plugins, because the idea is fundamentally the same. Capacitor can just take the same native files that the Cordova plugin is using and add them to the Capacitor project.
You can add Capacitor to an existing Cordova project without fear. If you do npx cap add android , Capacitor will create an android folder where it will put the Android native project. If you do npx cap add ios , Capacitor will create an ios folder where it will put the iOS native project.
As an alternative to Cordova, Capacitor delivers the same cross-platform benefits, but with a more modern approach to app development, taking advantage of the latest Web APIs and native platform capabilities.
Web Developers need to install the web dependencies of the plugins from npm . The packages are listed under the @capacitor scope. To install a plugin, run npm i @capacitor/<plugin_name> from the root of your web project.
Remember you can install the native wrapper too. It should work just the same as using it with Cordova.
npm install @ionic-native/qr-scanner
From:
ionic cordova plugin add cordova-plugin-qrscanner
npm install @ionic-native/qr-scanner
To:
npm install cordova-plugin-qrscanner
npm install @ionic-native/qr-scanner
npx cap sync
https://ionicframework.com/docs/native/qr-scanner
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With