0

Here is my code:

angular.module('app', ['ionic', 'ngMessages', 'ngCordova', 'jett.ionic.filter.bar',
'ion-datetime-picker', 'angularMoment', 'ngCordova.plugins.progressIndicator', 'ionic-timepicker']) //, $httpProvider
.config(configBlock)
// .factory('MyHttpInterceptor', MyHttpInterceptor)
.run(function ($ionicPlatform) {
  $ionicPlatform.ready(function () {
    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if (window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
});

But I got

"Cannot read property 'Keyboard' of undefined" error

once I run the command ionic serve. I have already added the plugin --> ionic-plugin-keyboard to my project. Can someone help me to find this issue?

5

1 Answer 1

1

Fix Only for Android :

Use window.Keyboard instead of cordova.plugins.Keyboard

Your code should like this :

if (window.cordova && window.Keyboard) {
    window.Keyboard.hideKeyboardAccessoryBar(true);
}

In the doc, it's written that there is a method called Keyboard.hideFormAccessoryBar. It's true for iOS but on Android, the method is called Keyboard.hideKeyboardAccessoryBar. You can check the js code in Keyboard.js file located under : file:///android_asset/www/plugins/cordova-plugin-ionic-keyboard/www/android/keyboard.js. Or you can use chrome://inspect/#devices to debug whats going on.

I hope this will fix your issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.