rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
288 stars 329 forks source link

location_permissions requestPermissions being denied #184

Open andrewzakhartchouk opened 3 years ago

andrewzakhartchouk commented 3 years ago

When trying out the example app provided in the package on an Android virtual device, I found that it was not attempting to request location permissions. Manually setting the app's permission in the settings menu fixed the problem.

However checking the code I found that the package location_permissions is non-existent, and thus the related code cannot function.

image image

Because there might be some additional setup for the example app that I didn't complete, I thought I would check here first before raising an issue at the location_permissions repository.

mehdok commented 3 years ago

HI @andrewzakhartchouk Thank you for opening an issue;

Did you update the location permission package?

andrewzakhartchouk commented 3 years ago

If by updating you mean pub get, yes I have. My location_permissions is version ^3.0.0+1.

UPDATE: Somehow the errors sorted themselves out, but pressing the Start button still does nothing.

Looking further, it seems in this point

final permission = await LocationPermissions().requestPermissions(
          permissionLevel: LocationPermissionLevel.locationAlways,
        );

the request is still being denied and returns PermissionStatus.denied

mehdok commented 3 years ago

By updating, I mean increasing the version of the library;

the request is still being denied and returns PermissionStatus.denied

I'll check this;

mehdok commented 3 years ago

I believe this is a location_permissions bug and there is nothing we can do on the library side. All we need is to just get location permission, you are free to use whatever is working for this matter;

andrewzakhartchouk commented 3 years ago

Thanks for looking into it. Perhaps I misunderstood how the permissions work, because if the app permission is set to 'Denied' then the location_permissions request won't work. Only if it's set to 'Allowed Only While In Use' will it automatically redirect to the app's permission page.

This also applies to the flutter-permission-handler.

My workaround ends up being using the app_settings package to redirect.

mehdok commented 3 years ago

I don't think you misunderstood something, something definitely has changed, because the default permission status should not be denied, I believe it should be not_determined or something similar;

Anyway, I would be more than happy to hear again from you and your solution for this problem;

andrewzakhartchouk commented 3 years ago

I can make a pull request for the example app that demonstrates using the app_settings package if you would like.

mehdok commented 3 years ago

I would appreciate it if you do so;