I am creating a simple Cordova/PhoneGap project.
I have added the Device plugin to the project and it works fine without any issues.
I see that there is a file called device.js file in the plugin's www folder.
Some examples online asks to include the plugin js file in the HTML code and some examples does not talk about it. My example works fine without using it.
When I add other plugisn like contacts also, I see the contacts.js file. This make me think twice.
I am confused whether I should use those JS file in my project.
It depends on what version of cordova the plugin is built for. In older versions you would have to include in the JS in your html file. In newer versions cordova_plugins.js includes these files for you. I would start by installing the plugin and then if it doesn't work, try adding the JS include. If it still doesn't work, the plugin may not be compatible with your version of cordova
You can check to see if a plugin has been added by looking through cordova_plugins.js
. This file is placed within each platform, here is iOS and Android:
Android: /platforms/android/assets/www
iOS: /platforms/ios/www
cordova.js
(the one file you do need to include in your html) looks for cordova_plugins.js
and includes it for you which then includes all the plugins listed within it.