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

GeolocationStatus.disabled isn't returned if Location is turned off #108

Closed
escamoteur opened this issue Sep 14, 2018 · 6 comments
Closed
Labels
type: enhancement New feature or request
Milestone

Comments

@escamoteur
Copy link

escamoteur commented Sep 14, 2018

Hi,

while testing I found that if the location service is disabled a call to geCurrentLocation just won't return until the service is switched on.

Calling checkGeolocationPermissionStatus doesn't help either because it will just return granted if the permissions are right and seems not to check id the service is available.

Cheers
Thomas

@escamoteur escamoteur changed the title Please add a fcuntion to check if location service is enabled GeolocationStatus.disabled isn't returned if Location is turned off Sep 14, 2018
@martijn00 martijn00 added this to the 2.1.0 milestone Sep 21, 2018
@martijn00 martijn00 added the type: enhancement New feature or request label Sep 21, 2018
@mvanbeusekom
Copy link
Member

This issue is being addressed in the following PR: Baseflow/flutter-permission-handler#32

@mvanbeusekom
Copy link
Member

@escamoteur we just release version 2.1.0 which implemented this feature. Let us know what you think.

@jfdeveloper92
Copy link

in 5.1.3 status is returning granted even when the location services are off.

this is my code. Maybe im doing something wrong?

GeolocationStatus geolocationStatus = await Geolocator().checkGeolocationPermissionStatus();
print(geolocationStatus.toString());

    if(geolocationStatus == GeolocationStatus.disabled){
      _showLocationMessage(message: "Please turn on location services", callback: (){
        Navigator.pop(context);
      });
      return;
    }

I am using a pixel 1 on 9.0
print(geolocationStatus.toString()); returns GeolocationStatus.granted when location is off.

@mvanbeusekom
Copy link
Member

Yes that is perfectly legal. The availability of the location service and the fact that permissions are granted are two separate entities.

You can still request permissions to access location information if the user has turned off the location services. You can use the isLocationServiceEnabled method to check if the location services are enabled or not and if necessary ask the user to turn them on if this is required for your App.

@jfdeveloper92
Copy link

Thank you. That worked as expected.

@ScholliYT
Copy link

ScholliYT commented Jan 4, 2020

Maybe this should be added to the main documentation. I find

to check if location services are enabled you can call the checkGeolocationPermissionStatus method

is very confusing related to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants