-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geolocation - Listening for location changes in the foreground #3678
Comments
@Eilon I'd like to get a discussion about this new feature to get started. How should I proceed, who should I ping for this? I can also prepare a PR if you like. |
Tagging @Redth and @mattleibow who know more about the Essentials library. |
I guess I'm waiting for #4634 to be merged and propose a new API? |
Is this something that was resolved? |
I'm also using the GeolocatorPlugin at the moment, and that's why I wrote this issue, but no one from the Essentials or MAUI team ever responded. |
@jamesmontemagno Any idea if this is something that will be supported in MAUI? |
A couple of things that I see here:
You mention that it goes to the Essentials namespace which doesn't exist anymore so probably the right place now will be Just thinking out loud for a bit here. If we think ahead a bit about maybe someday a background location listening functionality will be added. Can we still get away with all of this? If we can I'd love to not duplicate any of this but just be able to use it for that as well as much as we can and is useful. Thanks for putting this together @vividos! |
Thanks for the analysis, all good points!
About the background location updates: I think this is harder to do, and James' plugin makes some efforts, but my use case was only foreground listening. I think Shiny does that, but there are some more steps to set this up: https://shinylib.net/mobile/gps/index.html?tabs=android |
Very nice PR! Pretty much all looks good except the naming that Gerald pointed out. But also a point in the future and background. I think it is fine to have StartForeground and StartBackground as that is often separate things. They both can probably use the same event as well. My question is can they run simultaneously? I am thinking if we have both, the IsListening might be ambiguous... Maybe we have a StartForeground and then have a MoveToBackground concept (that could just stop foreground and start background). But if we want to support simultaneously background and foreground then the boolean may need renaming. |
Also good point, Matt! I think the property should for now be IsListeningForeground, to make the intent clearer. I'm still not sure if Essentials should implement background listening at all and better let Shiny implement that. |
@jfversluis I updated the API specification in the initial post with all the points that you and Matt brought up. I also found out that |
Description
Xamarin Essentials as well as MAUI Essentials have the Geolocation API that allows to get the current (or last known) location. James Montemagno's Geolocation plugin also has additional API calls to start/stop listening for location updates. In my apps (both hobby projects and professional work) I use these APIs for several use cases, which might benefit having the API directly in MAUI Essentials. Note that the feature request is just asking for foreground location changes, as I'm aware that background location updates are much more complicated to implement.
Note that the Geolocation foreground listener feature was previously proposed in Xamarin.Essentials, but didn't make the cut in 1.7.0. See:
Public API Changes
(all classes live in the namespace
Microsoft.Maui.Devices.Sensors
)Intended Use-Case
Note that all of these scenarios happen in the foreground. Background location requests are out of scope for this feature request.
The text was updated successfully, but these errors were encountered: