I’m not sure how to get Cordova plugins working with Ionic 4 + Capacitor in Android Emulator.
I am following this example (https://ionicacademy.com/create-pdf-files-ionic-pdfmake/) but I am going to add some Capacitor plugins to it in order to use the camera to add images.
Do the Cordova plugins below still work with Capacitor? I can’t get them to work at all. They work fine using cordova rather than Capacitor. I have created project as follows:
ionic start myApp
cd myApp
npm install @capacitor/core @capacitor/cli
npx cap init
npm install pdfmake @ionic-native/file-opener @ionic-native/file
npm install cordova-plugin-file-opener2
npm install cordova-plugin-file
*Writes code*
create myApp/www dir
copied index.html to myApp/www dir
npx cap add android
npx cap update
npx cap open android (opens android studio)
ionic capacitor run android
npx cap sync
npx cap copy
run in emulator from android studio
Expected Result:
pdf is saved to device and is then opened.
Actual result:
No warnings or errors in console.
Fails on this on line and does not proceed:
this.file.writeFile(this.file.dataDirectory, 'myletter.pdf', blob, { replace: true }).then(fileEntry => {
Update: Warnings and error resolved but still not working