Book Image

Phonegap Essentials

By : Ivan Turkovic
Book Image

Phonegap Essentials

By: Ivan Turkovic

Overview of this book

Table of Contents (15 chapters)

The Vibration plugin


The Vibration plugin provides access to the haptic motor that has been part of mobile devices since the invention of pagers, as they provide a discreet alert on updates that only you need to know. It provides a way to vibrate the device.

This is one of the plugins that you need to check regularly for changes since there is no complete support for all three major platforms and the features this plugin is providing. The iOS platform can only do one vibration at a time, while Android and Windows can do multiple vibrations in sequence. The plugin is defined as a global object through navigator.vibrate object.

To install the plugin, you need to run the following command:

phonegap plugin add cordova-plugin-vibration

The Vibration plugin provides a global navigator.vibrate object that is available only after the deviceready event is fired, so you need to listen for that event before performing an action or a pattern is emitted through the haptic motor.

document.addEventListener...