Phonegap for iOS を使用して最初のアプリを作成しています。加速度計の値を取得して、画面にアラートとして表示しようとしています。私はcordova-2.3.0の最新バージョンを持っています。index.html ファイルのコードは次のとおりです。
<!DOCTYPE html>
<html>
<head>
<title>PhoneGap Device Ready Example</title>
<script type=”text/javascript” charset=”utf-8” src=”cordova-2.3.0.js”></script>
<script type=”text/javascript” charset=”utf-8”>
document.addEventListener(“deviceready”, onDeviceReady, false);
function onDeviceReady() {
navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
}
// onSuccess: Get a snapshot of the current acceleration
//
function onSuccess(acceleration) {
alert('Acceleration X: ' + acceleration.x + '\n' +
'Acceleration Y: ' + acceleration.y + '\n' +
'Acceleration Z: ' + acceleration.z + '\n' +
'Timestamp: ' + acceleration.timestamp + '\n');
}
// onError: Failed to get the acceleration
//
function onError() {
alert('onError!');
}
</script>
</head>
<body>
<h1> Example </h1>
<p>getCurrentAcceleration </p>
</body
</html>
しかし、何も起こりません。Example と getCurrentAcceleration が書かれた白い画面が表示されます。
誰か助けてくれませんか?
ありがとう