I am new in developing on PhoneGap Build. While testing some basic app functionalities I experience a timeout problem when doing a simple geolocation request on my Iphone 6 / IOS 10 / PhoneGap Build 6.3.0.
After re-installing the app I start it and initiate the geolocation by onclick -> geolocation().
Only when I turn the app to the background, I receive the IOS request to allow the location request (should come when I first do the onclick -> geolocation while having the app in the foreground).
Sometimes I get a geolocation result after a long time, sometimes not. I've tried all possible combinations on the three PositionOptions.
When I ask the Google Maps app it shows me the location immediately.
Any idea what I am doing wrong?
Thank you, Kim
function do_geolocation(){
alert('do geoloc');
navigator.geolocation.getCurrentPosition(geo_onSuccess, geo_onError, {maximumAge:120000, enableHighAccuracy:false} );
}
onclick=do_geolocation();
function geo_onSuccess(position){
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
var arr = new Array();
arr['lat'] = position.coords.latitude;
arr['lng'] = position.coords.longitude;
var x = new Date();var cb = x.getTime();
}
function geo_onError(position){
alert('code: '+error.code+'\nmessage: '+error.message+'\n');
return false;
}
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "de.vvvvvv.secapp"
versionCode = "10"
version = "1.0.0" >
<!-- versionCode is optional and Android only -->
<name>vvvvvvv</name>
<description>
vvvvvvvvvvvv
</description>
<author href="http://vvvvvvv.de" email="info@vvvvvv.de">
Kim
</author>
<plugin name="cordova-plugin-geolocation" spec="2.4.1" />
<plugin name="cordova-plugin-whitelist" spec="1.3.1" />
<access origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<preference name="orientation" value="portrait" />
<!-- https://makeappicon.com/ios10icon -->
<icon src="res/icons/ios/Icon-App-20x20@2x.png" platform="ios" width="20" height="20" />
<icon src="res/icons/ios/Icon-App-20x20@3x.png" platform="ios" width="40" height="40" />
...