gktval / Maui-GeolocatorPlugin

Simple cross platform plugin to get GPS location including heading, speed, and more. Additionally, you can track geolocation changes, reverse geocode, and more.
MIT License
29 stars 6 forks source link

[Feature Request] Ability to request to enable GPS option if switched off on Android #6

Open gsk143 opened 1 year ago

gsk143 commented 1 year ago

As the title suggests is there a way to detect GPS and open the popup for enabling gps on Android? I am looking at this problem for a while but all solutions are either deprecated or don't work properly. It would be nice to have this feature.

gktval commented 1 year ago

Requesting permissions for using GPS should be handled by the developer prior to calling any request for GPS position updated.

If you are requesting continuous GPS updates, then the return value for StartListeningAsync() is Boolean, which will allow you to keep track in your own code of whether or not GPS is being consumed.

gsk143 commented 1 year ago

@gktval thanks for the response but when I say GPS I am not referring to the permissions but to check whether the GPS location is enabled or not. See the screenshot for more clarity. So something like this in code `PermissionStatus status = await Permissions.CheckStatusAsync();

    if (status == PermissionStatus.Granted)
    {
            var isGPSEnabled = CrossGeolocator.Current.IsGeolocationEnabled();
            if(isGPSEnabled)
            {
                //Go ahead and get the user location using Gelocatorplugin
            }
            else
            {
                //This method will show GPS request just like in maps (see 2nd screenshot)
                isGPSEnabled = CrossGeolocator.Current.EnableGPS();
            }
    }
    else
    {
        //user denied the location request so do something else
        //Re request the permission or show alert as to why you need it etc
    }

` Screenshot_1688535173 Screenshot_1688535747