Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Separate permission and service request #193

Open
MaxiSonntag opened this issue Jan 29, 2019 · 1 comment
Open

Separate permission and service request #193

MaxiSonntag opened this issue Jan 29, 2019 · 1 comment
Labels

Comments

@MaxiSonntag
Copy link

Hey folks,

I'm currently using this plugin in my NS-Angular app and came up to something that might improve readability and efficiency.
Info: I'm only testing on iOS right now due to #187

So, the method enableLocationRequest currently does two things at once, checking if the needed permissions are granted, and checking if the location services are enabled. However, only one of these possibilities is executed at once, so the method has to be called twice, if services are off and permissions are denied.

image-2019-01-29
image-2019-01-29-2

Another problem is, that after the redirection to settings (if services disabled), no callbacks are being called. This means, I have to call isEnabled, depending on the result I know if the next enableLocationRequest will request permissions or service.

I hope you can understand what I mean, the method does too much at once and does not give sufficient information about what just happened. I suggest to separate this one into permissions (which already works acceptable), and a new method, let's say checkLocationServices (with callbacks if possible), which opens the dialog if they are disabled, or returns some value if enabled.
Otherwise it could return an Observable that fires when services are toggled, this way you'd even be able to react if the user disables services on runtime (same for permissions imaginable).

Let me know what you think about this suggestion, maybe I'm just using the method wrong as well.

@tbozhikov
Copy link
Contributor

Hi @MaxiSonntag, this sounds reasonable to me and would enhance the development experience with the plugin. Indeed, though it could be tricky to implement, the callback(s) after redirection to Settings would be neat.
However, in terms of checking for location services in a separate method, there is a public method already - isEnabled().
If you have any concrete solutions, feel free to contribute. We would love to have PRs!

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

2 participants