Skip to content
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

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

Open
gsk143 opened this issue Jul 4, 2023 · 2 comments

Comments

@gsk143
Copy link

gsk143 commented Jul 4, 2023

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
Copy link
Owner

gktval commented Jul 4, 2023

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
Copy link
Author

gsk143 commented Jul 5, 2023

@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<Permissions.LocationWhenInUse>();

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants