JohnGood February 2016

ios html5 geolocation - no error when browser has no rights to use geolocation

When using html5 geolocation, everything works nicely in the computer browser, but after switching to an iphone I get no error when user has phone settings set to not allow browser to use geolocation, is there any way to trigger error in such situation? navigator.geolocation.getCurrentPosition(handleSuccess, handleError) I'm using this code to get current position and my handleError is never triggered

Answers


Willian Dallastella February 2016

Did you try to validate the object navigator.geolocation ?

function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        throw "Geolocation is not supported by this browser.";
    }
}
function showPosition() {
    // my code
}
getLocation();

Post Status

Asked in February 2016
Viewed 3,745 times
Voted 10
Answered 1 times

Search




Leave an answer