almost 5 years ago
By using cordova-plugin-vibration we can get vibration on the devices. The plugin has some global objects like navigator.vibrate.
cordova plugin add cordova-plugin-vibration
The vibrate function provides the three functionalities that we can use to vibrate the devices.
It vibrates the device for a given period of time.
-time: in milliseconds
navigator.vibrate(2000); //vibrate for 2 seconds
navigator.vibrate(); //vibrate for 2 seconds
Vibrate with a pattern:
It is only for the Android and Windows.
we can vibrate the device with a specific pattern by using this.
Pattern:It defines the durations (in milliseconds) of vibration in sequences for which we can turn on or turn off the vibration.
// Vibrate for 5 second
// Wait for 3 second
// Vibrate for 2 seconds
// Wait for 1 second
// Vibrate for 6 seconds
navigator.vibrate([5000, 3000, 2000, 1000, 6000]);
Cancel vibration:It is not supported in IOS
It will cancel the vibration that is currently running on the device.
That means we can pass an empty array or parameter 0 or an array with first element value 0. That will cancel any vibrations.
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
© copyright 2017 FindNerd.com. All rights reserved.
Sign up using