flutter-permission-handler
flutter-permission-handler copied to clipboard
iOS is permenantlyDenied when trying to get camera permission, even when it is enabled in app settings
🐛 Bug Report
iOS is permenantlyDenied when trying to get camera permission, even when it is enabled in app settings
Expected behavior
If you have camera enabled, then the permission is granted
Reproduction steps
Check perm status when you call it, when you have permission granted -> var perm = await Permission.camera.request();
Configuration
Simulator - iPhone 12 (iOS 15.5) Version: 1.x ^10.0.0
Platform:
- [ X] :iphone: iOS
- [ ] :robot: Android
I have the same for camera and mediaLibrary permission. Is there any workaround?
@novas1r1 , @haydgately : Do you have some code snippets to show how you are checking and requesting for camera permissions? I had a similar issue where it would keep asking camera permission even if the camera permissions were enabled in app settings. I managed to get around that by first checking for status and then ask to open app settings if the permission is not granted. Something like this:
PermissionStatus cameraPermissionStatus = await permissionService.cameraStatus();
if (cameraPermissionStatus != PermissionStatus.granted) {
PermissionStatus permissionStatus = await permissionService.requestCameraPermission();
if (permissionStatus != PermissionStatus.granted) {
openDialog(context, ‘Camera disabled’, ‘Allow permission to access the camera in your device setting’ , [
DialogAction(‘Cancel’, () {
Navigator.pop(context);
}),
DialogAction(‘Go to app settings, () async {
await openAppSettings();
})
]);
}
}
}
Hope this helps.
And you would also need this in your ios/Podfile
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
And you would also need this in your ios/Podfile
## dart: PermissionGroup.camera 'PERMISSION_CAMERA=1',
more detail see step3 :https://www.jianshu.com/p/cebd00a7cc16
Do you check it in applifecycle of the app? Example:
void didChangeAppLifecycleState(AppLifecycleState state) { if (state == AppLifecycleState.resumed) { PermissionHandler() .checkPermissionStatus(PermissionGroup.locationWhenInUse) .then(_updateStatus); } }
Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.