Book Image

Phonegap Essentials

By : Ivan Turkovic
Book Image

Phonegap Essentials

By: Ivan Turkovic

Overview of this book

Table of Contents (15 chapters)

Essential plugins

Since, in the latest PhoneGap version, no plugins are added by default, it was decided to keep the app builds as small and lightweight as possible. We are free to enhance the app based on our needs, but this could be challenging for beginners as there are so many plugins it is hard to decide which ones to start with. I have selected a few that, in my opinion, are essential and should be included in the core. So let's go over them and see what capabilities they enable.

The Device plugin

The Device plugin defines a global device object that describes the device's hardware and software information. The Device plugin is available only after the deviceready event has been used.

phonegap plugin add cordova-plugin-device

After installing the plugin, let us create an example of how it could be used. Generally, it is used for testing for the specific platform or model:

document.addEventListener('deviceready', function(event) {
  var content = "";
  content += "Version: " + device.cordova...