Chrome IOS HTML5 geolocation permission denied

14,366

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.

Share:
14,366
chad
Author by

chad

Updated on July 20, 2022

Comments

  • chad
    chad almost 2 years

    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

  • chad
    chad almost 12 years
    This does not work for mobile chrome on ios. Just opened the fiddle up on my phone and it gives me the same behavior as my code above.
  • mattnull
    mattnull almost 12 years
    weird.. I did the same thing and it worked on my phone... do you have location services turned on? This maybe needs to be enabled
  • mattnull
    mattnull almost 12 years
    So I noticed that once you deny it once, and then reload.. it will continue to say permission denied... I think this is because it adds an exception into Chrome to deny further access.
  • chad
    chad almost 12 years
    interesting, im pretty sure that I never denied it, but i'll try to look into the chrome exceptions