watchPosition on iOS with Location Services OFF hangs
I'm having a problem with geolocation.watchPosition. I've scoured the
boards, but I didn't find a post that has this specific issue.
Here is my PhoneGap version:
name="phonegap-version" value="2.9.0" />
Here is some of my code:
var waitTimerVal = 10*1000; // milliseconds
var options = { enableHighAccuracy:true, timeout:waitTimerVal,
maximumAge:60000};
watch_id = navigator.geolocation.watchPosition(onSuccess, onError, options);
// onError Callback receives a PositionError object
function onError(error) {
var perror;
switch(error.code)
{
case error.PERMISSION_DENIED:
perror="Req.Den."
error_cnt++;
//alert(perror);
break;
case error.POSITION_UNAVAILABLE:
perror="No.Pos."
error_cnt++;
//alert(perror);
break;
case error.TIMEOUT:
perror="Poor..."
error_cnt++;
//alert(perror);
break;
case error.UNKNOWN_ERROR:
perror="Error"
error_cnt++;
//alert(perror);
break;
}
}
// onSuccess Geolocation
function onSuccess(position) {
lat = position.coords.latitude;
lng = position.coords.longitude;
alt = position.coords.altitude;
accuracy = position.coords.accuracy;
}
This works perfectly on my Android (4.2.1), but on my iPhone. I am running
this on iOS 6.1.3.
On iOS, if the Location Services are enabled, this works fine. On iOS, if
the Location Services are disabled, it makes my app just hang.
Oddly, on Android, I get the POSITION_UNAVAILABLE enum each iteration when
I turn of Location Services on my phone (I thought it would have been
PERMISSION_DENIED, but it's not... maybe I just didn't wait long enough
iterations)
I check the number of error_cnt values, and if it exceeds a certain
number, I pop up a message. On the Android, I get that message. On iOS, I
don't. So I know the callbacks are not being invoked.
Does anyone have an idea of what may be causing this, and a suggested work
around?
Thanks in advance.
No comments:
Post a Comment