ios 4.1 doesn't call Phonegap API
Posted
by
Johannes Klauß
on Stack Overflow
See other posts from Stack Overflow
or by Johannes Klauß
Published on 2011-11-29T17:47:46Z
Indexed on
2011/11/29
17:50 UTC
Read the original article
Hit count: 321
I'm working on a cross platform app for Android 2.2 and iOS 4.1 (dev devices). On Android everything works fine (accelerometer and geolocation) even if it's a little laggy.
On iOS it's way more smooth, but he doesn't call the Phonegap functions. That's my JS code:
var watchID = null;
var shaking = {
left: false,
right: true
};
function startWatch() {
// Update acceleration every 100 ms
var options = {
frequency : 100
};
watchID = navigator.accelerometer.watchAcceleration(function(acceleration) {
if(acceleration.x < -8) {
shaking.left = true;
}
else if(acceleration.x > 8) {
shaking.right = true;
}
if(shaking.left && shaking.right) {
navigator.notification.vibrate(500);
shaking.left = false;
shaking.right = false;
stopWatch();
}
}, null, options);
}
I just call it with
<a href="" onclick="startWatch();">start Accel</a>
But iOS doesn't react at all. Is there any special call you need to do in iOS?
© Stack Overflow or respective owner