5

I want to open the camera by clicking a button but cannot add the camera and gallery permissions in the iOS package.

I have those keys:

NSPhotoLibraryUsageDescription
NSCameraUsageDescription
NSMicrophoneUsageDescription

And I don't know where I should put those lines.

Abdurrahman Anas
  • 665
  • 2
  • 9
  • 21

5 Answers5

14

edit this file:

[Flutter Project Folder]/ios/Runner/Info.plist

add these entries:

<key>NSPhotoLibraryUsageDescription</key>
<string>App needs access to photo lib for profile images</string>

<key>NSCameraUsageDescription</key>
<string>To capture profile photo please grant camera access</string>

the string part can be any description you want the user to see as an explanation for why your app needs these privileges

these lines should be added after the tag

there is a good elaboration for other options here: https://stackoverflow.com/a/39519960/530884

Shaybc
  • 2,628
  • 29
  • 43
2

To add permissions in Flutter, you must add permissions to both the AndroidManifest.xml file and the info.plist file.

To add the specific permissions you are asking to the info.plist, you can go to:

iOS -> Runner -> info.plist

enter image description here

tomerpacific
  • 4,704
  • 13
  • 34
  • 52
1

Take a look at the example project for the camera package: https://github.com/flutter/plugins/blob/master/packages/camera/camera/example/ios/Runner/Info.plist

You'll see that those lines are in with the rest of them.

tim-montague
  • 16,217
  • 5
  • 62
  • 51
Benjamin
  • 5,783
  • 4
  • 25
  • 49
0

Permissions for gallery, camera, and microphone (etc) should be added to the ios/Runner/info.plist file, just before the UILaunchStoryboardName key.

<dict>
    <!-- permissions -->
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Please grant photo gallery access</string>
    <key>NSCameraUsageDescription</key>
    <string>Please grant camera access</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>Please grant microphone access</string>
    <!-- end permissions -->
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
</dict>

Note that a plist file is tab-delimited, so you should not use spaces.

tim-montague
  • 16,217
  • 5
  • 62
  • 51
0

you should try by updating the podfile

You can follow this link

By this you can set the permission by default and on the permission dialog, it'll update the permission