views:

168

answers:

1

When trying to get geolocation on iPhone the first time - I declined. Every other time I want to get the location (before another reload of the page) I get no response (no error and no success):

navigator.geolocation.getCurrentPosition(
    function (location) {
        ig_location.lat = location.coords.latitude;
        ig_location.lng = location.coords.longitude;
        alert('got it!');
    },
    function(PositionError) {
        alert('failed!' + PositionError.message);
    }
);

Is there a way to notify the user every time I fail to get the location?
(I do not need to use watchPosition...)

+1  A: 

The Geolocation API is designed so that it doesn't annoy the user with repeat requests after they decline. You can reset the location warnings from the settings app, but that's about all you can do.

Once the user declines geolocation permission twice in a row, the API will assume they don't want it and not ask again.

Exact wording from the Core Location documentation:

If the user denies your application’s use of the location service, this method reports a kCLErrorDenied error. Upon receiving such an error, you should stop the location service.

Jasarien
Thanks for the answer.for other people looking for the actual document - its at: http://developer.apple.com/iphone/library/documentation/CoreLocation/Reference/CoreLocation_Framework/CoreLocation_Framework.pdf
Dror