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

[Bug]: Camera is Already Granted But Camer.status always return denied.

Open Chantha123 opened this issue 1 year ago • 9 comments

Please check the following before submitting a new issue.

Please select affected platform(s)

  • [ ] Android
  • [X] iOS
  • [ ] Windows

Steps to reproduce

1 . Call Permission.camer.request(); 2 . Check Status after request

Expected results

The result should show permission is granted

Actual results

The result that's function status return denied

Code sample

Code sample
await Permission.camera.request();    
PermissionStatus permissionStatus = await Permission.camera.status; 
if (permissionStatus.isDenied || permissionStatus.isPermanentlyDenied) {
  isCamera = true;
}  

Screenshots or video

Screenshots or video demonstration

[Upload media here]

Version

11.1.0

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.16.5, on macOS 14.2.1 23C71 darwin-arm64, locale en-KH)
    • Flutter version 3.16.5 on channel stable at /Users/kungchantha/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 78666c8dc5 (3 weeks ago), 2023-12-19 16:14:14 -0800
    • Engine revision 3f3e560236
    • Dart version 3.2.3
    • DevTools version 2.28.4

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/kungchantha/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C65
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.76.0)
    • VS Code at /Users/kungchantha/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.80.0

Chantha123 avatar Jan 08 '24 04:01 Chantha123

I already follow all config but the result is incorrect.

Chantha123 avatar Jan 08 '24 04:01 Chantha123

We're also seeing this on iOS 17. No matter what the status, it is always returned as denied

mrmko avatar Jan 08 '24 13:01 mrmko

fyi, clearing my pods folder and .symlinks and rerunning pod install seems to have fixed the issue for me

mrmko avatar Jan 08 '24 13:01 mrmko

I have got the same issue with ios. Always getting the status PermissionStatus.permanentlyDenied.

rohnsht avatar Jan 09 '24 05:01 rohnsht

Any workaround?

YonatanSegura97 avatar Jan 10 '24 16:01 YonatanSegura97

We're seeing the same issue, on iOS physical device and on simulator. await Permission.camera.request() returns isPermanentlyDenied instantly, without ever asking the user to allow camera use. And because that request is never sent to the OS, you can't enable the camera in the iOS settings menu for that app either.

The temporary workaround that "worked" for us was to ignore the isPermanentlyDenied status entirely and just open the camera anyway - the operating system provided the popup to allow camera that we were looking for. But now we can't distinguish between a true isPermanentlyDenied status and one where the user simply hasn't been asked.

tony-ditchlabs avatar Jan 17 '24 15:01 tony-ditchlabs

Same issue, and I have updated to lastest version of this lib. Any update?

2e2ee95304418f96 avatar Jan 23 '24 10:01 2e2ee95304418f96

It seem like we need to add the below code in Podfile.

Start of the permission_handler configuration

target.build_configurations.each do |config|
  config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
    '$(inherited)',

    ## dart: PermissionGroup.calendar
    # 'PERMISSION_EVENTS=1',

    ## dart: PermissionGroup.reminders
    # 'PERMISSION_REMINDERS=1',

    ## dart: PermissionGroup.contacts
    # 'PERMISSION_CONTACTS=1',

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

    ## dart: PermissionGroup.microphone
    # 'PERMISSION_MICROPHONE=1',

    ## dart: PermissionGroup.speech
    # 'PERMISSION_SPEECH_RECOGNIZER=1',

    ## dart: PermissionGroup.photos
    # 'PERMISSION_PHOTOS=1',

    ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
    # 'PERMISSION_LOCATION=1',
      
    ## dart: PermissionGroup.notification
    # 'PERMISSION_NOTIFICATIONS=1',

    ## dart: PermissionGroup.mediaLibrary
    # 'PERMISSION_MEDIA_LIBRARY=1',

    ## dart: PermissionGroup.sensors
    # 'PERMISSION_SENSORS=1',   
       
    ## dart: PermissionGroup.bluetooth
    # 'PERMISSION_BLUETOOTH=1',

    ## dart: PermissionGroup.appTrackingTransparency
    # 'PERMISSION_APP_TRACKING_TRANSPARENCY=1',

    ## dart: PermissionGroup.criticalAlerts
    # 'PERMISSION_CRITICAL_ALERTS=1'
  ]
end

You need to add this inside post_install as below:

post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target)

# Start of the permission_handler configuration
target.build_configurations.each do |config|
  config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
    '$(inherited)',

    ## dart: PermissionGroup.calendar
    # 'PERMISSION_EVENTS=1',

    ## dart: PermissionGroup.reminders
    # 'PERMISSION_REMINDERS=1',

    ## dart: PermissionGroup.contacts
    # 'PERMISSION_CONTACTS=1',

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

    ## dart: PermissionGroup.microphone
    # 'PERMISSION_MICROPHONE=1',

    ## dart: PermissionGroup.speech
    # 'PERMISSION_SPEECH_RECOGNIZER=1',

    ## dart: PermissionGroup.photos
    # 'PERMISSION_PHOTOS=1',

    ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
    # 'PERMISSION_LOCATION=1',
      
    ## dart: PermissionGroup.notification
    # 'PERMISSION_NOTIFICATIONS=1',

    ## dart: PermissionGroup.mediaLibrary
    # 'PERMISSION_MEDIA_LIBRARY=1',

    ## dart: PermissionGroup.sensors
    # 'PERMISSION_SENSORS=1',   
       
    ## dart: PermissionGroup.bluetooth
    # 'PERMISSION_BLUETOOTH=1',

    ## dart: PermissionGroup.appTrackingTransparency
    # 'PERMISSION_APP_TRACKING_TRANSPARENCY=1',

    ## dart: PermissionGroup.criticalAlerts
    # 'PERMISSION_CRITICAL_ALERTS=1'
  ]
end 

end end

rohnsht avatar Jan 25 '24 02:01 rohnsht

Dear @Chantha123, and the others,

I cannot reproduce this on the example app. Please be sure that you added the configuration like @rohnsht. If you still encounter any issues feel free to add information to this issue. Or start a new issue.

Kind regards,

TimHoogstrate avatar Feb 07 '24 11:02 TimHoogstrate

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 Feb 21 '24 12:02 github-actions[bot]

我在ios上也有同样的问题。始终获得PermissionStatus.permanentlyDenied状态。

How did you solve it

tang158152 avatar Jul 12 '24 02:07 tang158152