0

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?

theshadow124
  • 661
  • 3
  • 8
  • 29

1 Answers1

0

Just in case anyone else has this issue, I found the solution from the second comment on this question: Location Service in UIWebView on iOS8 beta 5 not working

Simply: Uninstall the app and re-install it using XCode then BOOM works fine.

Community
  • 1
  • 1
theshadow124
  • 661
  • 3
  • 8
  • 29