IPhone : navigator.geolocation.getCurrentPosition not timing out for iPhone5

on Wednesday, February 25, 2015

I have the following code in a location service:



.factory('Location', function($q, $ionicLoading) {
return {
getCurrentPosition: function() {
var deferred = $q.defer();
$ionicLoading.show({template: 'Getting Location...'});
navigator.geolocation
.getCurrentPosition(
function (data) {
$ionicLoading.hide();
deferred.resolve(data);
},
function (error) {
var data = 'Error getting current position.';
$ionicLoading.hide();
deferred.reject(data);
},
{timeout:5000, enableHighAccuracy:false});
return deferred.promise;
}
}
}


I use PhoneGap Build to build the project and then install on my iPhone5.


All works fine till I turn off Location services:


enter image description here


I expect the timeout to occur after 5 seconds and the error to display. However, my app just hangs. Any ideas timeout is not triggered?


0 comments:

Post a Comment