Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome IOS HTML5 geolocation permission denied

When trying to use the HTML5 geolocation api on mobile chrome for ios, my app throws a "Permission Denied" error without even prompting to share my location. Has anyone else run into this issue?

PS. This happens locally and on a heroku instance.

Here is the code I am running on document ready

    var displayCloseFoo = function(position) {
        var lat = position.coords.latitude;
        var lon = position.coords.longitude;

    };

    var displayError =  function(error) {
        var errors = {
            1: 'Permission denied',
            2: 'Position unavailable',
            3: 'Request timeout'
        };
        alert("Error: " + errors[error.code]);
    };

    var runGeo =  function(){
        if (navigator.geolocation) {
            var timeoutVal = 10 * 1000 * 1000;
            navigator.geolocation.getCurrentPosition(
                    displayCloseFoo,
                    displayError,
                    { enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }
            );
        }
        else {
            alert("Geolocation is not supported by this browser");
        }
    };
    runGeo();

Thanks

like image 693
chad Avatar asked Jul 16 '12 16:07

chad


People also ask

What does User denied geolocation mean?

Problem: GPS Status screen reports 'User denied location' in Chrome browser on Android phone/tablet. Solution: This error message means that you need to give your phone or tablet permission to access the GPS.


1 Answers

You have to explicitly allow Mobile Chrome to use Location Services in ios. In ios6 you can achieve this by going to Settings->Privacy->Location Services and toggling Chrome to On.

like image 100
chad Avatar answered Sep 23 '22 01:09

chad