Search code examples
javascriptcordovacordova-pluginsvisual-studio-cordova

Cordova cordova.plugins is undefined on win8 but not on iOS


I'm using the plugin fileopener2 and to use it, I must call cordova.plugins.fileopener2.open(...);

When I run this on iOS, everything works perfectly. However, when I run the app on win8, I get an error telling me that cordova.plugins is undefined. Also, I double checked that, after 'ondeviceready' is fired, I console.log the value of cordova.plugins and it indeed returns an undefined value. Can anyone point me as to how I can fix this issue?


Solution

  • For Cordova Windows8 applications (or all applications built with Visual Studio), if your plugin is a custom one (I would assume it's not part of the org.apache...), you have to manually add it. Go to the config file in your www through visual studio. You will see three tabs: Core/Custom/Installed. Go to Custom, go to your cordova project, then in the plugins, find your custom plugin and add the folder of the plugin and voila, it will work!