Reputation: 2428
I created a new Cordova 4.0 project, added android platform and added all the core plugins and the following is my index.html file.
<!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() {
alert("ready");
}
// 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.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>
But I could never see the device ready firing. Any ideas on what is wrong with the abive snippet ?
Upvotes: 0
Views: 1182
Reputation: 1079
Try to change
<script type="text/javascript" charset="utf-8" src="/cordova.js"></script>
to
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
Upvotes: 1