Github user avishekcode commented on the issue:

    https://github.com/apache/cordova-plugin-geolocation/pull/87
  
    @shazron @filmaj 
    Hi!
    
    I literally, just downloaded the current plugin, and without my 
modification, I get these warnings constantly via Xcode, while testing on 
iPhone 5s:
    2017-04-26 17:45:32.151697-0400 TabCab Inc[3927:2025999] THREAD WARNING: 
['Geolocation'] took '10.250000' ms. Plugin should use a background thread.
    2017-04-26 17:45:32.256468-0400 TabCab Inc[3927:2025999] THREAD WARNING: 
['Geolocation'] took '33.067871' ms. Plugin should use a background thread.
    2017-04-26 17:45:52.700650-0400 TabCab Inc[3927:2025999] THREAD WARNING: 
['Geolocation'] took '25.637939' ms. Plugin should use a background thread.
    2017-04-26 17:46:18.191620-0400 TabCab Inc[3927:2025999] THREAD WARNING: 
['Geolocation'] took '10.547852' ms. Plugin should use a background thread.
    
    Device: iPhone 5s, but I believe it happens even in newer phones, if I am 
using the plugin for applications like Uber (Motion capture in the background).
    
    Now, I apologize if I broke some rules while trying to implement the 
solution. I will try to dig into the rules, and any quick suggestion how to fix 
the problem otherwise?
    
    My solution puts the function in background thread, stops all warnings, and 
it increases the performance of the plugin and the overall app.
    
    My use of the plugin in my applications, is as follows:
    function getAccurateGPS(GPSok,GPSerr,GPSing,options,Abort)
    {
        var lastPos,locECnt=0,watchID,navTim;options=options || {};
        
if(Abort){clearTimeout(navTim);navTim=null;navigator.geolocation.clearWatch(watchID);}
        else
        {       var checkLocation=function(position)
                {       lastPos=position;locECnt=locECnt+1;     //Ignore first 
event unless it's the only one because some devices send cached location even 
with maxaimumAge=0
                        if((position.coords.accuracy<=options.desiredAccuracy) 
&& 
(locECnt>1)){clearTimeout(navTim);navTim=null;navigator.geolocation.clearWatch(watchID);foundPos(position);}else{GPSing(position);}
                };
                var 
stopTrying=function(){navigator.geolocation.clearWatch(watchID);foundPos(lastPos);};
                var 
onError=function(error){clearTimeout(navTim);navTim=null;navigator.geolocation.clearWatch(watchID);GPSerr(error);};
                var foundPos=function(position){GPSok(position);};
                if(!options.maxWait)                    options.maxWait=10000;
                if(!options.desiredAccuracy)    options.desiredAccuracy=5;
                if(!options.timeout)                    
options.timeout=options.maxWait;
                options.maximumAge=0;options.enableHighAccuracy=true;
                
watchID=navigator.geolocation.watchPosition(checkLocation,onError,options);
                navTim=setTimeout(stopTrying,options.maxWait);//Timeout
        }
    }
    
    Basically, my applications require constant motion tracking, and I try to 
capture the most accurate position available.
    
    Please let me know if there is anything else you need from me, or if you 
have any suggestions.
    
    Thanks!



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to