简体   繁体   中英

Ionic app with both capacitor and Cordova

I am very much confused on building an ionic 4 app that is based on capacitor. I am also using few cordova plugins and syncing them using an npx cap sync. Is it an ideal way to do so? Currently I am trying to use the background-mode plugin in my app. For that I came across both these options:

https://ionicframework.com/docs/native/background-mode

https://capacitor.ionicframework.com/docs/apis/background-task/

I was thinking of going ahead with the cordova plugin, but I am still not sure how to decide which plugin to use in my project.

App details :

Ionic:

   Ionic CLI                     : 5.2.4 (C:\Users\user\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.11.7
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.0.0

Capacitor:

   Capacitor CLI   : 1.4.0
   @capacitor/core : 1.1.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 9 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.3.0

System:

   NodeJS : v10.16.2 (C:\Program Files\nodejs\node.exe)
   npm    : 6.9.0
   OS     : Windows 10

Can anyone guide me on this?

Having worked with both, i can say that most of the plugins which have been already designed for cordova, are compatible with capacitor..if they are not, it is explicitly mentioned on the ionic website. Read this part of the official docs to understand more. For using cordova plugins with capacitor, see this .

In your case, for your confusion regarding which plugin to use, consider these two points.

  1. See what functionality you want to use from the plugin. What is it that you want the plugin to do. Then compare which out of these two fulfills that purpose.

  2. It is always better to use the plugin which is in built in capacitor. Like the background task one. You won't have to install and manage any separate package for them. Just update capacitor and you receive the latest plugin with it. This will also keep your app lighter in size. Much more future proof as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM