flutter-permission-handler icon indicating copy to clipboard operation
flutter-permission-handler copied to clipboard

Gets Permission Granted Status for Limited Permission.

Open rashidkhaleefa opened this issue 2 years ago • 2 comments

🐛 Bug Report

The Permission.location.status method is returning PermissionStatus.denied if the location service is limited (precise location disabled) in iPhone (>14). (Note: I experience the same for photo access also)

Expected behaviour

Expects the plugin to return PermissionStatus.limited while the user has not enabled the precise location in iPhone

Reproduction steps

  1. Make a fresh install of the app.
  2. Call Permission.location.status which will bring up the iOS permission dialog.
  3. Disable the precise location on the top left corner.
  4. Select on Allow while using the app.
  5. Now the plugin will return permission granted instead of limited state.

Version: 8.2.2

Platform:

  • [x] :iphone: iOS 14 +
  • [ ] :robot: Android

rashidkhaleefa avatar Oct 07 '21 07:10 rashidkhaleefa

Thanks for reporting your issue. I tried reproducing your issue, but when requesting the Permission.photos the PermissionStatus.limited value will show up, as expected. In case of the Permission.location request: Apple does not distinguish Approximate Location / Precise Location in terms of Authorization Status, so it is expected that PermissionStatus.granted will be returned for both Approximate Location and Precise Location. Take a look at: https://developer.apple.com/documentation/corelocation/clauthorizationstatus?language=objc, for more info.

Although it is possible to distinguish Approximate Location / Precise location by making use of the CLAccuracyAuthorization enum, I don't think it fits the permission_handler. See for more info: https://developer.apple.com/documentation/corelocation/claccuracyauthorization?language=objc. Do you think using the CLAccuracyAuthorization enum would be a better approach?

florissmit1 avatar Oct 08 '21 11:10 florissmit1

Yes I think checking for accuracy and setting it to the status would help. Specifically for applications that required precise location.

switch locationManager.accuracyAuthorization {
       case .reducedAccuracy:
        // limited access case here
       case .fullAccuracy:
} 

Its the similar case for PhotoAccess permission too. Again I understand it's perfectly depends on the use case but, For iOS >14 it is difficult to understand if we have limited access or complete access to photos.

if #available(iOS 14, *) {
            PHPhotoLibrary.requestAuthorization(for: .readWrite) { (status) in
                switch status {
                case .limited:
                  // limited access case here
                    break
                case ..
                }
            }
        }

rashidkhaleefa avatar Oct 08 '21 14:10 rashidkhaleefa

The current version of the permission_handler will return the granted status no matter if the user allowed precise or reduced location access.

Adding more details regarding the accuracy of the locations settings is beyond the scope of this plugin. Plugins like the Geolocator or Location can provide detailed information on the set location precision.

mvanbeusekom avatar Sep 14 '23 15:09 mvanbeusekom