I've been unable to find a solution to this, on my website I'm loading in a Webview I have the following javascript function that is run after the page finishes loading:
var latitude, longitude, accuracy;
function setGeolocation() {
accuracy = 5000;
var geolocation = window.navigator.geolocation.watchPosition(
function ( position ) {
if (position.coords.accuracy < accuracy){
latitude = position.coords.latitude;
longitude = position.coords.longitude;
accuracy = position.coords.accuracy;
loc = latitude + "," + longitude;
}
if (accuracy < 50) window.navigator.geolocation.clearWatch( geolocation );
},
function () { /*error*/ }, {
maximumAge: 250,
enableHighAccuracy: true
}
);
window.setTimeout( function () {
window.navigator.geolocation.clearWatch( geolocation );
}, 5000 //stop checking after 5 seconds
);
};
I've added the following to my Plist file:
- Privacy - Location Usage Description
- NSLocationAlwaysUsageDescription
- NSLocationWhenInUseUsageDescription
And imported CoreLocation.Framwork
Any ideas why this doesn't work?