开发者

user disallowed geolocation - notify user second time

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...)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜