Window.cordova is undefined in ionic


#1

I created a blank project in ionic. In the www/js/app.js with the following code:

angular.module('starter', ['ionic', 'ngCordova'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      console.log("works!");
    }else {
      console.log("nopes");
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
});

I always get nopes in the console. Why is that so? Why is window.cordova undefined?


#2

Is cordova.js loaded ?
Other issue might be that you don’t have the keyboard plugin installed


#3

If you mean when running in dev mode with ionic serve that’s normal, window.cordova will only be defined when running on iOS or Android.


#4

Hello, Someone solve this problem? I have exact thing, cordova.js is not loaded so I have message ‘nope’ from code above. Also I use device for debugging so I should works but not…


#5

When I open the app via Ionic View it said that window.cordova isn’t defined…

Is cordova available only when project is built and started as particular app?


#6

Looks like u were able to see the Logs when using Ionic View . Please advise how to debug in Ionic View ?
Thanks


#7

Android Monitor :wink: It’s in de the SDK