Flutter-permission-handler: iOS request permission no reaction and status return undetermined all the time

Created on 14 May 2020  ·  4Comments  ·  Source: Baseflow/flutter-permission-handler

🐛 Bug Report


Request permission no reaction, and permission status all return undetermined even if I refuse or accept the permission.

Expected behavior

working properly

Reproduction steps

 Permission.photos.request().then((value) => print(value));

...terminal print
PermissionStatus.undetermined

Configuration

Info.plist

<!-- Permission options for the `photos` group -->
        <key>NSPhotoLibraryUsageDescription</key>
        <string>photos</string>

Podfile

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'

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

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

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

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

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

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

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

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

      ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
      # 'PERMISSION_LOCATION=0',

      ## dart: PermissionGroup.notification
      # 'PERMISSION_NOTIFICATIONS=0',

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

      ## dart: PermissionGroup.sensors
      # 'PERMISSION_SENSORS=0'
      ]
    end
  end
end

Version: 5.0.0+hotfix.5
Flutter Doctor

[✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.15.4 19E287, locale zh-Hans-CN)
    • Flutter version 1.17.1
    • Framework revision f7a6a7906b (29 hours ago), 2020-05-12 18:39:00 -0700
    • Engine revision 6bc433c6b6
    • Dart version 2.8.2


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/lvyan/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.45.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.1

[✓] Proxy Configuration
    • HTTP_PROXY is set
    • NO_PROXY is localhost,127.0.0.1
    • NO_PROXY contains 127.0.0.1
    • NO_PROXY contains localhost

[✓] Connected device (1 available)
    • iPhone 11 Pro Max • CA5D6F5C-7D84-4500-9502-38AFE83F87DD • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)

Platform:

  • [✅] :iphone: iOS
  • [ ] :robot: Android
ios question

All 4 comments

Hi @lvyandev, the problem here is the line in your Podfile where you say:

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

This actually tells the plugin to remove the part where we access the iOS PHPhotoLibrary SDK so that Apple static code analyser doesn't think you are using it when you upload your app to the App Store.

By default the permission_handler plugin assumes you want to use all SDKs and you can use the above code to disable these SDKs. This means that by default all macros are set to 1 (i.e. 'PERMISSION_PHOTOS=1') and by setting it to zero you are telling the plugin not to use the SDK. So in your case where you do want to use the PHPhotoLibrary SDK, you need to switch things around. So the solution would be to uncomment all SDKs you don't want to use and make sure you comment all SDKs you do want to use.

Oh, I'll give it a try, sry. I'm an android developer.

It works, thanks for your help! XD

Glad I could help ;)

Was this page helpful?
0 / 5 - 0 ratings