Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova plugins not work with Ionic

I am building out an Ionic app in Angular and ave never been able to get plugins to work.

As an example, I have tried using the statusbar plugin as described here:

http://ionicframework.com/tutorials/fullscreen-apps/

But it still shows in my app. I tried:

$ cordova plugin add org.apache.cordova.statusbar

and then "cordova prepare", "ionic run ios" and still no luck.

The plugins I get listed when I type

$ cordova plugin list

com.ionic.keyboard 1.0.2 "Keyboard"
org.apache.cordova.console 0.2.10 "Console"
org.apache.cordova.device 0.2.11 "Device"
org.apache.cordova.statusbar 0.1.7 "StatusBar"

I also am using Gulp. I have a folder with all my dev work in, and gulp moves and compiles it into a /dist folder from whence it is served. I'm pretty sure the plugins are moved across perfectly, is there anywhere I should check the references?

Any ideas if there is something you have to do in order to use Cordova plugins with Ionic?

like image 224
Ben Taliadoros Avatar asked Sep 11 '14 17:09

Ben Taliadoros


People also ask

Does ionic use Cordova or Capacitor?

Ionic's flagship open source project, Ionic Framework, supports both Cordova and Capacitor, but the decision between the two becomes more important for enterprises looking for official support, and alignment with the rest of the Ionic stack.

How do I add plugins to ionic project?

First, log into the Ionic Hub, then navigate to the Native Plugins Keys page. Click Assign to App , then New App . Enter a name, then click Create App .

Can I use Capacitor and Cordova together?

Capacitor can just take the same native files that the Cordova plugin is using and add them to the Capacitor project.


1 Answers

The answer to this was that I had to add

<script src="cordova.js"></script>

to my page, just above my scripts.

Please be aware this file doesnt exist during development, it's injected at runtime... which is why I could solve it. Hope this helps someone!

like image 163
Ben Taliadoros Avatar answered Sep 20 '22 07:09

Ben Taliadoros