Chrome IOS HTML5 geolocation permission denied
Asked Answered
I

3

11

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

Intussusception answered 16/7, 2012 at 16:43 Comment(2)
Is your iOS Simulator running? It is known to cause the location services of the host machine to stop working.Polyneuritis
No. This is a mobile web app, not native.Intussusception
I
5

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.

Intussusception answered 23/9, 2012 at 16:19 Comment(0)
P
0

Geolocation will not work locally in Chrome... Not sure why it wouldn't work from your Heroku instance

Check out this Fiddle... it seems to work fine here... http://jsfiddle.net/mattnull/YaCRe/

Perpetuity answered 15/8, 2012 at 3:25 Comment(4)
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.Intussusception
weird.. I did the same thing and it worked on my phone... do you have location services turned on? This maybe needs to be enabledPerpetuity
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.Perpetuity
interesting, im pretty sure that I never denied it, but i'll try to look into the chrome exceptionsIntussusception
G
-1

After installing the chrome.when it gets open,it asks u to share your location if u denied u will not get the location

Gelatinoid answered 2/5, 2013 at 10:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.