navigator.geolocation.getCurrentPosition(onSuccess, onError);
var options = { timeout: 30000, timeout:27000, enableHighAccuracy: false };
watchID = navigator.geolocation.watchPosition(onSuccess, onError, options);
2015-04-16 12:02:21.873 Jambuster[2175:376997] onWatchPositionFailure: Failure {"code":3,"message":"Position retrieval timed out."}
2015-04-16 12:02:21.874 Jambuster[2175:376997] onWatchPositionFailure: Failed
2015-04-16 12:02:37.756 Jambuster[2175:376997] onWatchPositionSuccess: Success {"coords":{"latitude":51.4XXXXXXXXXXX,"longitude":-0.01XXXXXXXXXXXX,"accuracy":65,"altitude":7.154781341552734,"heading":-1,"speed":-1,"altitudeAccuracy":10},"timestamp":"2015-04-16T11:02:37.742Z"}
2015-04-16 12:02:40.760 Jambuster[2175:376997] onWatchPositionFailure: Failure {"code":3,"message":"Position retrieval timed out."}
2015-04-16 12:02:40.761 Jambuster[2175:376997] onWatchPositionFailure: Failed
2015-04-16 12:02:48.665 Jambuster[2175:376997] onWatchPositionSuccess: Success {"coords":{"latitude":51.4XXXXXXXXXXX,"longitude":-0.0XXXXXXXXXXXX,"accuracy":65,"altitude":6.991412162780762,"heading":-1,"speed":-1,"altitudeAccuracy":10},"timestamp":"2015-04-16T11:02:48.652Z"}
2015-04-16 12:02:51.740 Jambuster[2175:376997] onWatchPositionFailure: Failure {"code":3,"message":"Position retrieval timed out."}
2015-04-16 12:02:51.740 Jambuster[2175:376997] onWatchPositionFailure: Failed
2015-04-16 12:02:57.413 Jambuster[2175:376997] onWatchPositionSuccess: Success {"coords":{"latitude":51.4XXXXXXXXXXX,"longitude":-0.0XXXXXXXXXXXX,"accuracy":50,"altitude":8.248470306396484,"heading":null,"speed":0,"altitudeAccuracy":4},"timestamp":"2015-04-16T11:02:57.398Z"}
2015-04-16 12:03:00.599 Jambuster[2175:376997] onWatchPositionFailure: Failure {"code":3,"message":"Position retrieval timed out."}
2015-04-16 12:03:00.600 Jambuster[2175:376997] onWatchPositionFailure: Failed
2015-04-16 12:03:01.279 Jambuster[2175:376997] onWatchPositionSuccess: Success {"coords":{"latitude":51.4XXXXXXXXXXX,"longitude":-0.0XXXXXXXXXXXX,"accuracy":30,"altitude":8.348445892333984,"heading":null,"speed":0,"altitudeAccuracy":4},"timestamp":"2015-04-16T11:03:01.271Z"}
2015-04-16 12:03:04.467 Jambuster[2175:376997] onWatchPositionFailure: Failure {"code":3,"message":"Position retrieval timed out."}
2015-04-16 12:03:04.467 Jambuster[2175:376997] onWatchPositionFailure: Failed
I've blanked out my exact position but I call tell you I live in London, UK. I don;t care about the altitude unless the Thames's floods.
I do get some errors whilst it settles down but I've just looked at the Xcode output and have had no updates, either for positional changes or errors in the last three minutes. So I can say for certain that the constant behaviour updating does not occur on an iPhone 5s running 8.2. I also have a Nexus 5 running Lollipop but I lent that to a friend yesterday and so can't test it on that. I'll try it when I get it back.
Also to comment on other suggestions.
You cannot run timers in the background in iOS, if you use the Xcode simulator it allows you to, Kerri and I had a little discussion on this a few weeks ago, which is where I discovered that the Xcode iOS simulator is more of a "it works a bit like this but its not an exact science". You can run timers in the background there but when you move the code to a iPhone it stops working.
If you want to run geolocation in the background, the only way I have found on iOS is
https://github.com/christocracy/cordova-plugin-background-geolocation
This works well but the Android version is very different and you need to stump up for an Android version that works the same way as iOS. We will be buying it as the cost isn't bad and we can't develop it for that price :)
As you suggest, we monitor if we are in the foreground and use one method, once we move to the background we use the background geolocation methods. It was quite easy to implement. However note that the background geolocation codes works differently and that the resolution seems to be more granular as it works on a change in position and that can vary how much is needed.
I would also ask the question of if you really want geolocation to work in the background. We use background GPS recording as we record and learn peoples routes to and from work for our app. Does your use-case really need it? We thought it was essential and then worked out we only needed it for one specific case. Of course YMMV.
We have also found that the watchPosition code as opposed to the content polling of the GPS position, at least on iOS is quite efficient and doesn't seem to drain the battery that much. The screen is the biggest drain and that takes around 50% of the battery as far as we can see. We haven't implemented background GPS positions on Android yet but its on our very near to-do list.
Hope this helps,
Rob
--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.