Apache Cordova geolocation.watchPosition () timeout on iOS while standing

When using Apache Cordova cordova-plugin-geolocation, specifically with watchPosition (), I ran into difficulties from at least iOS 8.1.3 to 8.3. It happens that when the user is moving, the coordinates work very well and are constantly updated. However, when the user pauses for a few seconds (say a set timeout), a timeout error is generated. The second user moves again and the coordinates work.

We cannot increase the timeout too much for fear that users will legitimately lose reception and overwrite their field boundaries again (agricultural application). However, we increased the timeout to 65000 and were still able to get the timeout message.

My current working theory is that for some reason, if no motion is detected, the plugin throws a timeout message rather than giving me the same coordinates over and over. I'm not sure if this could be some sort of battery saving feature or an actual bug with iOS and / or plugin.

geoWatch = window.navigator.geolocation.watchPosition(
    gpsChangeCoordinates,
    function(error){
        $("#signal").html("Error: "+error.message);
        $("#signal").css("background-color","red");
    },
    {maximumAge:3000, timeout:15000, enableHighAccuracy:true});
);

      

Switching to getCurrentPosition () is also invalid, because unless GPS is constantly tried out, accuracy will not be achieved and will remain at levels required for agricultural purposes.

This issue does not appear on Android.

+3


source to share


1 answer


The solution is a modification of CDVLocation.m directly to remove distanceFilter. Or more specifically:

if (enableHighAccurary) {
    // snipped
    // self.locationManager.distanceFilter = 5;// original, causes problems standing still
    self.locationManager.distanceFilter = kCLDistanceFilterNone;
    //snipped
} else {

      



Based on the comments in the code, this was a conscious decision on behalf of the battery to only send updates when the user moves 5 meters or more. This is problematic for my use cases.

+5


source







All Articles