0

how can i trace geolocation every 30 second even app in background i'm using navigator geolocation plugin (navigator.geolocation.getCurrentPosition) in app to get location.and i tried it with setinterval but plugin doesn't work when app in background process.

please someone guide me it's for android and ios for both plateform!

Savoo
  • 933
  • 7
  • 14
  • hello @AnujGupta i use this { maximumAge: 3000, timeout: 30000, enableHighAccuracy: true } it's not giving accurate interval like 30 sec – Savoo Aug 23 '16 at 12:50
  • is it giving result on 5 sec ? – Anuj Aug 23 '16 at 12:55
  • no ! now i change my option to {maximumAge: 0, timeout: 20000, enableHighAccuracy: true Output is : 08-23 18:30:06 , 08-23 18:30:47 , 08-23 18:33:27 some time it's give result in sec difference and sometime in minutes like it's give last result after 3 min – Savoo Aug 23 '16 at 13:04
  • I will work on that again. I also raised this quesion http://stackoverflow.com/questions/38585556/watchposition-time-out-in-geolocation but didn't get answer of it ,Will work on this issue on next week – Anuj Aug 24 '16 at 10:45

1 Answers1

0

I worked on it today, Now it is working fine even in background, I am getting response from it after 1 minute. I used setinterval()

 setInterval( function(){
      navigator.geolocation.getCurrentPosition(success_loc, error_loc, opti)
    },(1000 * 60 * 1));

Use success_loc for Success and error_loc for showing error,opti for optional variable to show option like

   var opti = {
                timeout: (5 * 1000), maximumAge: (1000 * 60 * 1), enableHighAccuracy: true
                };
Anuj
  • 640
  • 7
  • 26