- Overview
- Platform Support
- The Command-Line Interface
- Platform Guides
- Using Plugman to Manage Plugins
- The config.xml File
- Icons and Splash Screens
- Embedding WebViews
- Plugin Development Guide
- Privacy Guide
- Whitelist Guide
- Accelerometer
- Camera
- Capture
- Compass
- Connection
- Contacts
- Device
- Events
- File
- Geolocation
- Globalization
- InAppBrowser
- Media
- Notification
- Splashscreen
- Storage
This version of the documentation is outdated!
Click here for the latest released version.
notification.beep
The device plays a beep sound.
navigator.notification.beep(times);
- times: The number of times to repeat the beep. (Number)
Supported Platforms
- Amazon Fire OS
- Android
- BlackBerry WebWorks 5.0+
- iOS
- Tizen
- Windows Phone 7 and 8
- Windows 8
Quick Example
// Beep twice!
navigator.notification.beep(2);
Full Example
<!DOCTYPE html>
<html>
<head>
<title>Notification Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
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>
Amazon Fire OS Quirks
- Amazon Fire OS plays the default Notification Sound specified under the Settings/Display & Sound panel.
Android Quirks
- Android plays the default Notification ringtone specified under the Settings/Sound & Display panel.
Windows Phone 7 and 8 Quirks
- Relies on a generic beep file from the Cordova distribution.
Tizen Quirks
-
Tizen implements beeps by playing an audio file via the media API.
-
The beep file must be short, must be located in a
sounds
subdirectory of the application's root directory, and must be namedbeep.wav
.