Flutter/iOS: Integrated plugin requests camera permission which is not required in app

560

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.

Share:
560
S-Man
Author by

S-Man

Author Advanced PostgreSQL Querying ISBN 978-3752967340

Updated on January 01, 2023

Comments

  • S-Man
    S-Man over 1 year

    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?

  • S-Man
    S-Man over 2 years
    Yes, indeed this is my intermediate solution. But I really search for a better one... Thank you nonetheless :)
  • croxx5f
    croxx5f over 2 years
    Good luck!, but as plugins are designed in flutter I do not believe a better one exists.
  • S-Man
    S-Man over 2 years
    Are your quite sure about it? I am pretty sure that 'PERMISSION_CAMERA = 0' is no permission. It already worked until I added my QR plugin. Before that, no issue raised. So, I am sure although the Podfile was as it is. So without the additional plugin and with 'CAMERA=0' everything was fine. So, as already stated, I have no issue with the permission_handler but the new plugin.
  • Dhaval Kansara
    Dhaval Kansara over 2 years
    @S-Man Please check setup guidelines of Permission-handler. pub.dev/packages/permission_handler#setup
  • Dhaval Kansara
    Dhaval Kansara over 2 years
    @S-Man Also they have done some changes in podfile setup for permissions. Please check the changelog of version 8.0.0: pub.dev/packages/permission_handler/changelog#800 Also I have edited the answer as well for your clear understanding.
  • S-Man
    S-Man over 2 years
    Yes, as you can see in your linked document they state "e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'" which is exactly what I did. So, I am still sure, that for permission handler everything is fine but not with my QR plugin...
  • Dhaval Kansara
    Dhaval Kansara over 2 years
    @S-Man please either you are using permission or not... you have to add all the permission groups in the podfile... the only thing you have to take care of in your case is just make PERMISSION_CAMERA = 1 commented not PERMISSION_CAMERA = 0 and make sure you don't have NSCameraUsagePermission in your info.plist file it will fix your problem surely.
  • S-Man
    S-Man over 2 years
    Once more ;) PERMISSION_CAMERA = 1 enables the permission according to the docs: pub.dev/packages/permission_handler#setup I want to disable it. That's why it is set to 0 (which is correct acc. to the in the documentation linked podfile: github.com/Baseflow/flutter-permission-handler/blob/master/…‌​) Moreover, this macro is ONLY for permission_handler plugin, not for my newly added QR plugin, isn't it? So I have no issue with the preprocessor macro, it's ok, I believe. I need to tell the QR plugin, not to use the permission.
  • Dhaval Kansara
    Dhaval Kansara over 2 years