I'm testing this simple geolocation code and it's not working on iOS devices for some reason. I've tested on MacOS, Windows, Windows Phone, Android phones, etc and it works as it should on all.
I always receive the "POSITION_UNAVAILABLE" error after granting permission.
navigator.geolocation.getCurrentPosition(
function success(position) {
var primary = getUniqueId();
var url = endpointBaseurl +
'?property_code=' + propertyCode +
'&distribService=' + distribService +
'&lat=' + position.coords.latitude +
'&lon=' + position.coords.longitude +
'&distribTarget=' + primary;
//Update the line below to be one of your links.
addMenuItem('Offers', url);
},
function error(err) {
switch (err.code) {
case 1:
alert("You must allow location in order to receive tobacco offers. Please refresh and try again.")
break;
case 2:
alert('POSITION_UNAVAILABLE');
break;
case 3:
alert('Error 3');
break;
default:
alert("Unable to determine your location. Please refresh and try again.");
}
}, options);
I've tested on physical devices as well as through Browserstack. The site is running on HTTPS.
Any ideas on why should isn't working or how I should go about debugging? I'm pulling my hair out over this one.