- Accelerometer
- Camera
- Capture
- Compass
- Connection
- Contacts
- Device
- Events
- File
- Geolocation
- Globalization
- InAppBrowser
- Media
- Notification
- Splashscreen
- Storage
- Getting Started Guides
- Command-Line Usage
- Privacy Guide
- Upgrading Guides
- Project Settings
- Plugin Development Guide
- Domain Whitelist Guide
- Embedding WebView
This version of the documentation is outdated!
Click here for the latest released version.
notification.vibrate
Vibrates the device for the specified amount of time.
navigator.notification.vibrate(milliseconds)
- time: Milliseconds to vibrate the device. 1000 milliseconds equals 1 second (
Number
)
Supported Platforms
- Android
- BlackBerry OS 5 - 7 (not supported for BlackBerry 10)
- iPhone
- Windows Phone 7 and 8
- Bada 1.2 & 2.x
Quick Example
// Vibrate for 2.5 seconds
//
navigator.notification.vibrate(2500);
Full Example
<!DOCTYPE html>
<html>
<head>
<title>Notification Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
// Empty
}
// Show a custom alert
//
function showAlert() {
navigator.notification.alert(
'You are the winner!', // message
'Game Over', // title
'Done' // buttonName
);
}
// Beep three times
//
function playBeep() {
navigator.notification.beep(3);
}
// Vibrate for 2 seconds
//
function vibrate() {
navigator.notification.vibrate(2000);
}
</script>
</head>
<body>
<p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
<p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p>
<p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p>
</body>
</html>
iPhone Quirks
-
time: Ignores the time and vibrates for a pre-set amount of time.
navigator.notification.vibrate(); navigator.notification.vibrate(2500); // 2500 is ignored