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

iOS is permenantlyDenied when trying to get camera permission, even when it is enabled in app settings

Open haydgately opened this issue 2 years ago • 5 comments

🐛 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

haydgately avatar Jun 30 '22 00:06 haydgately

I have the same for camera and mediaLibrary permission. Is there any workaround?

novas1r1 avatar Jul 03 '22 18:07 novas1r1

@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.

tashiwangdi avatar Jul 04 '22 08:07 tashiwangdi

And you would also need this in your ios/Podfile

## dart: PermissionGroup.camera
        'PERMISSION_CAMERA=1',

tashiwangdi avatar Jul 05 '22 11:07 tashiwangdi

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

zzdota avatar Jul 19 '22 05:07 zzdota

Do you check it in applifecycle of the app? Example:

void didChangeAppLifecycleState(AppLifecycleState state) { if (state == AppLifecycleState.resumed) { PermissionHandler() .checkPermissionStatus(PermissionGroup.locationWhenInUse) .then(_updateStatus); } }

themmfa avatar Aug 23 '22 12:08 themmfa

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.

github-actions[bot] avatar Nov 23 '23 14:11 github-actions[bot]