Replies: 4 comments 1 reply
-
Would be nice to also have something like |
Beta Was this translation helpful? Give feedback.
-
The way I do is using:
This can throw a However, this is not a good solution. This call can take a number of seconds and sometimes I can't block the app for that. |
Beta Was this translation helpful? Give feedback.
-
I'm gonna bump this "discussion". I'm using quotation marks here, because let's face it: This should be marked as an Issue, as it is clearly not working as intended. There's currently (at least on those android devices I've tested) no way to check if the Gps Feature is enabled/disabled other than to make a GeolocationRequest, wrap it in a trycatch statement and to assume that the feature is disabled if the request throws an error. This is a basic feature, that should've been implemented way before deprecating Xamarin.Forms and forcing us to switch to Maui (such as many other vital and basic features, that are missing). At least I'd appreciate some statement from one of the developers, when we can expect a FIX to this ISSUE. |
Beta Was this translation helpful? Give feedback.
-
Would love to see a fix for this too. In the meantime, you could possibly catch the exception and do something within that catch-block. For example, show a popup to ask the user to manually turn on their location, or notify the user that location services are not supported on their device:
Note that in debug-mode, VisualStudio may still throw an exception. When running the app in release mode the exception is not thrown, and your catch-block code will be executed instead. |
Beta Was this translation helpful? Give feedback.
-
Description
To clarify: I'm know how to request permission for coarse/fine location. I'm looking for a way to detect, if the location tracking on the device is enabled or not. ComptonAlvaro requested this as well here and I'm really not sure why this issue was marked as resolved. The offered solution solution (checking it via the permission API if something is possible/available) does not work, as checking the permission status via
await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
returns
PermissionStatus.Granted
even if the devices location tracking is disabled (at least on android).
Checking if the Location Service is enabled by
await Geolocation.GetLocationAsync()
doesn't work either, as it throws an exception:
**Microsoft.Maui.ApplicationModel.FeatureNotEnabledException:** 'Location services are not enabled on device.'
Public API Changes
Intended Use-Case
My App doesn't require location to be on to be used but I want remind users to enable it, as it increases the the functionality of my App. Also I only want to check for the user's location if the Location Service is enabled.
Beta Was this translation helpful? Give feedback.
All reactions