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

Add method to check if user has disabled geolocation services #640

Closed
squio opened this issue Sep 30, 2021 · 2 comments
Closed

Add method to check if user has disabled geolocation services #640

squio opened this issue Sep 30, 2021 · 2 comments
Labels

Comments

@squio
Copy link

squio commented Sep 30, 2021

Feature Request

Plugin

@capacitor/geolocation

Description

Currently the checkPermissions() and requestPermissions() only check for and enable the App permissions.
The device user can still have location services disabled - which is undetectable by this plugin.

On Android, location services are required to be enabled to do a Bluetooth scan request.
If location services are not available, the BLE stack does not generate any error messages but just
times out and discovers nothing (by design).

I want to be able to check whether location services have been disabled globally without trying to get an actual location because I actually don't want to request the user location at all.

Platform(s)

  • Android (primarily)
  • iOS (could be useful as well?)

Preferred Solution

Implement the solution from PR #589 as a callable plugin method, something along the lines of:

public bool checkLocationServices()
{
    LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    return (LocationManagerCompat.isLocationEnabled(lm));
}

A similar requestLocatuinServices() method - which requests the user to enable location services - could be helpful as well.

Alternatives

As my use case is purely related to Bluetooth scanning, this could also be added in
plugin @capacitor-community/bluetooth-le
but the feature feels more at place in the actual geolocation plugin.

Additional Context

It seems that similar functionality may exist in some (outdated?) cordova plugins but I'm very
hesitant to pollute my project with duplicate and potentially outdated functionality.
Alternative suggestions are welcome though!

@jcesarmobile
Copy link
Member

I think the Bluetooth plugin would be a better fit for this feature, geolocation will return an error if the location services are disabled.

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 30, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants