Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Perform gps tracking in background mode

$
0
0

Hi, I'm developing an application that makes gps tracking in background mode. It works relatively well, but I suspect it does not trigger the "location" event of Titanium.Geolocation correctly.

If I'm using a filterDistance of 10 meter and ACCURACY_BEST, because it may be that the event sometimes not work?.

Look at the picture to understand better. image

In the simulator works perfect.

I can force it to use the GPS instead of cell towers ?.

My test environment is:

Ti SDK: 3.4.0 iPhone 5 ios 8

and

iPhone 4 ios 7

My code:

Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
    Titanium.Geolocation.distanceFilter = 10;
 
    var locationCallback = function(e)
    {
        if (!e.success || e.error)
        {
            lblMessage.text = JSON.stringify(e.error);
            return;
        }
        var latitude = e.coords.latitude;
        var longitude = e.coords.longitude;
        var accuracy = e.coords.accuracy;
 
        if (accuracy<500){
            var testPin = MAP.createAnnotation({
                latitude: latitude,
                longitude: longitude,
                pincolor: MAP.ANNOTATION_GREEN,
                title: (new Date()).toTimeString() 
            });
            mapview.addAnnotation(testPin);
        }
        else{
            lblMessage.text = L("bad_accuracy");
        }
    };
 
 
    Titanium.Geolocation.addEventListener('location', locationCallback);
Thank you !!

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>