cordova-background-geolocation-services
cordova-background-geolocation-services copied to clipboard
Get posiotion always
How to get geolocation not only in "background mode"?
Hi,
I have the same issue. I'm looking for a normalized Android/iOS solution to watch the current location utilizing the latest fused location services, etc. I think this is "just" a foreground implementation of this plugin. If so, is this easy to achieve, or have I got it completely wrong?!
Cheers, Darren
There's no reason I couldn't implement Foreground tracking in this plugin. But I figured there are plugins out there to do this already, so there isn't much point.
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-geolocation/
Hi Paul,
Thanks for that. I do currently use the Apache plugin but I wasn't aware it used the latest technologies like Android Fused Location services, etc.
I'm a PHP/JavaScript coder so this is all a bit new to me. Can you poke me into the right area to modify your excellent work into a foreground task? It will give me a little challenge to do in the Christmas break :)
Cheers, Darren
The easy way to do that would be to put this line right into the start command (after the request to permissions has been made), and remove the onPause / onResume functions.
Hey @pmwisdom,
Well, now I have little chaos, so. For sample, I have application with map, where is being my position tracked and it's showed on map, and when I switch to another application, my position will be still tracked. If I good understand, I need a combined foreground/background service?
Thanks
Thanks @pmwisdom
I'll have a play over the next week and see how far I can get :)
Have a great New Year, Cheers, Darren
@GAMELASTER Correct, you need both.
@pmwisdom Oh okay. And then, how it works? When application is foreground, I getting position via classical module, and when it's minimized, background getting information? (and then combining them?)
Thank you a lot!
@GAMELASTER Yep you got it. Watch the events for background / foreground and switch which plugin your using.
Hi @pmwisdom
I had a play with this over the past few days without much success. I commented out the onPause/onResume overrides and send a broadcast to start recording on the action start if we have permission. Sadly, this does not seem to report consistent updates of the users current position in foreground mode.
It's a shame but I think I'm out of my depth trying to emulate the navigator.geolocation functionality with the latest Android/iOS goodies. :( I'll keep watching for those to catch up.
Thanks for your advice anyway, Cheers, Darren
+1
Erm figured some example source might help everyone:
https://github.com/pmwisdom/meteor-combined-geolocation
If anybody wants, I have a generic npm style rewrite of this, I just haven't published it since its so similar to the original, it just uses imports.