flutter-permission-handler
flutter-permission-handler copied to clipboard
Gets Permission Granted Status for Limited Permission.
🐛 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
- Make a fresh install of the app.
- Call Permission.location.status which will bring up the iOS permission dialog.
- Disable the precise location on the top left corner.
- Select on Allow while using the app.
- Now the plugin will return permission granted instead of limited state.
Version: 8.2.2
Platform:
- [x] :iphone: iOS 14 +
- [ ] :robot: Android
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?
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 ..
}
}
}
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.