Getting undefined error with ionic Keyboard

Hello,
I’m getting an error in those lines:

$ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      //cordova.plugins.Keyboard.disableScroll(true);
    }
}

When serving the application with phonegap serve, it says:

[phonegap] [console.log] Error: TypeError: ‘undefined’ is not an object (evaluating ‘window.cordova.plugins.Keyboard’)

If I run phonegap plugin list from cmd, It says that com.ionic.keyboard 1.0.2 “Keyboard” is installed.

What am I doing wrong?
Thanks in advance! :smile:

Have you added the keyboard plugin to your project?

and to avoid those errors check if window.cordova.plugins is defined…

Hello, I know I can avoid the error checking if it is defined, but that’s not the scope of this topic… what I need is to get the plugin working.

How can I check if the plugin is correctly added to my project?

Thanks in advance

If the project was created from the command line, then plugin should already be installed

but to check to see if it is, use this

cordova plugin ls

Already tried that.
Command outputs:

com.ionic.keyboard 1.0.2 "Keyboard"
org.apache.cordova.console 0.2.9 "Console"
org.apache.cordova.device 0.2.10 "Device"

Hmm, is this with regular cordova, or phonegap build?

I’m using phonegap’s cli “phonegap serve” command to serve the application to “Phonegap Developer App” to Test it in my iOS devices

Ok, well that will explain things. The developer app for phonegap doesn’t handle plugins

Wow… Sorry, I didn’t know that. :anguished:

Thanks for your help

No worries, they don’t really say that anywhere to be honest. I had to find out the hard way myself.

Hi,
I have the same issue, and I’m using ‘ionic build’, and ‘ionic run’.

Cordova CLI: 6.2.0
Ionic Framework Version: 1.3.1
Ionic CLI Version: 1.7.16
Ionic App Lib Version: 0.7.3
OS: Windows 7 SP1
Node Version: v4.4.4

Any help is really appreciated. And my cordova camera plugin crashes the app on ios.

Many thanks,
epsilonpsi

Do you know how I can get this resolved with a plugin that I have downloaded? I’m getting this same error, but I’m serving out of xcode to an iPad and every time it get undefined is not an object (evaluating ‘cordova.plugins.unimag.swiper.activate’). Here is my plugin list:

com.wodify.cordova.plugin.unimag-swiper 0.0.2 "Cordova-Plugin-UniMag-Swiper"
cordova-plugin-console 1.0.3 "Console"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-splashscreen 3.2.2 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-whitelist 1.2.2 "Whitelist"
ionic-plugin-keyboard 2.2.1 “Keyboard”