skip to Main Content

In my iOS/Flutter app, I am using a QR reader plugin. My requirement is to recognize QR data from images only, not from the camera. But the plugin offers both.

So, I don’t need the camera permission in my app and therefore I didn’t add this to the Info.plist file.

Unfortunately, Apple refused the app due to Missing Purpose String: NSCameraUsagePermission.

Because I also integrated the plugin permission_handler, I have already added this to my podfile:

  config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
    '$(inherited)',

    ...

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

    ...
  ]

I thought this helps me with exactly the described issues: Add permission, a plugin requests but is not required in my app. Obviously, it does not.

Is there a way to achieve that: Deny the camera permission while using the requesting plugin nonetheless?

2

Answers


  1. Last time I had an issue like this I wrote the permission description in the info.plist and made it explicit that the permission was not used. In your case it should be something like this.

    <key>NSCameraUsageDescription</key>
    <string>Not used but enfored by a dependency</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Read QR codes from saved images</string>
    

    And apple did accepted my app despite that. It should be fine as long as you are explicit with it.
    If they do reject it I would probably fork the plugin and drop the Permission in the code.

    Login or Signup to reply.
  2. As per permission_handler guidelines you have to mark all those permission as commented which you are not using in the app.


    As per plugin guidelines, Remove the # character in front of the permission you do want to use. For example, if you need access to the camera make sure the code looks like this:

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

    In your case, you have added 'PERMISSION_CAMERA=0' in podfile, So Apple expected permission for the camera in info.plist file and it’s missing over there. So update your podfile as below.

    config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
            '$(inherited)',
    
            ## dart: PermissionGroup.calendar
            # 'PERMISSION_CAMERA=1',
    ]
    

    Note: Whatever permission you are making uncommented in podfile, make sure you add permission for the same in info.plist file and also add a proper description(purpose of using that permission in your app).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search