cordova-background-geolocation-services icon indicating copy to clipboard operation
cordova-background-geolocation-services copied to clipboard

Get posiotion always

Open denyzhirkov opened this issue 8 years ago • 12 comments

How to get geolocation not only in "background mode"?

denyzhirkov avatar Dec 18 '16 22:12 denyzhirkov

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

Daz66 avatar Dec 23 '16 13:12 Daz66

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/

pmwisdom avatar Dec 23 '16 21:12 pmwisdom

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

Daz66 avatar Dec 24 '16 10:12 Daz66

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.

pmwisdom avatar Dec 24 '16 23:12 pmwisdom

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

gamelaster avatar Dec 26 '16 17:12 gamelaster

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

Daz66 avatar Dec 27 '16 13:12 Daz66

@GAMELASTER Correct, you need both.

pmwisdom avatar Dec 27 '16 18:12 pmwisdom

@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 avatar Dec 27 '16 18:12 gamelaster

@GAMELASTER Yep you got it. Watch the events for background / foreground and switch which plugin your using.

pmwisdom avatar Dec 28 '16 18:12 pmwisdom

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

Daz66 avatar Jan 04 '17 13:01 Daz66

+1

diegobill avatar Jan 23 '17 03:01 diegobill

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.

lanmower avatar Aug 21 '17 12:08 lanmower