Baseflow / flutter-permission-plugins

This repo contains a collection of permission related Flutter plugins which can be used to request permissions to access device resources in a cross-platform way.
https://baseflow.com
MIT License
52 stars 34 forks source link

[location][ios] whenInUse returns denied #13

Closed mockturtl closed 4 years ago

mockturtl commented 5 years ago

🐛 Bug Report

When requesting location permission on iOS, the user selects "only when in use." The plugin returns "denied."

Expected behavior

"Granted," or maybe "restricted." (Have I misunderstood the semantics here? If it's a matter of what the default PermissionLevel.location means on Android vs iOS, please document the difference!)

Reproduction steps

From a Flutter iOS app, call requestPermissions(). Choose "When in use" from the prompt. See "denied" logged as the return value.

https://github.com/BaseflowIT/flutter-permission-plugins/blob/develop/packages/location_permissions/ios/Classes/LocationPermissionsPlugin.m#L195

https://github.com/BaseflowIT/flutter-permission-plugins/blob/develop/packages/location_permissions/ios/Classes/LocationPermissionsPlugin.m#L108

Configuration

Version: 2.0.2

Platform:

chaicai333 commented 5 years ago

i have the same problem

KingWu commented 5 years ago

Have the same issue

mvanbeusekom commented 4 years ago

@mockturtl this is expected behaviour and only occurs when your "Info.plist" doesn't include the correct permissions.

In this case you are actively requesting "locationAlways" permissions while the permissions in your "Info.plist" only contain the NSLocationWhenInUseUsageDescription key.

You have two solutions here:

  1. Don't request "locationAlways" permissions (e.g. switch to "locationWhenInUse");
  2. Or add the missing permissions to your "Info.plist";

Hope this helped solve your issue.

mockturtl commented 4 years ago

@mvanbeusekom Thank you for the reply and the workaround. I did discover both your suggestions through trial and error, and they solved it, but it was a little frustrating.

In this case you are actively requesting "locationAlways" permissions

That's confusing, to me. I call the API with the default value for the optional parameter, LocationPermissionLevel.location. To me, that means I am actively not requesting a different value.

enum LocationPermissionLevel {
  location,  // is this Android only?  What does it mean in Android 10?
  locationWhenInUse,
  locationAlways,
}

Please reconsider documenting this behavior, or the intended usage -- judging by the upvotes, it could be a little more clear.

@athornz