My problem is thus: I would like to run the watchAcceleration() when I
am on the iPhone but NOT when I am running the app in the simulator.
When I try in the simulator, the app stops running for some reason I
can't discern. I tried doing:
if (typeof(PhoneGap) != 'undefined') {
alert("accel: "+ navigator.accelerometer.watchAcceleration);
return;
}
to no avail and I tried
if (navigator.accelerometer != null) {
}
but that doesn't work either. How can I tell [in Javascript] which
environment its running in?
Thanks,
Gabriel
Are you running your app inside of PhoneGap in the simulator, or just
as a regular webapp? The
if (typeof(PhoneGap) != 'undefined')
technique will work, but only if you use Mobile Safari to navigate
directly to your ~/sites/phonegap/iphone/www/index.html file.
- Steve