Flutter学习

使用permission_handler,添加权限后获取权限仍然

2021-06-23  本文已影响0人  CodeLuck

写flutter,需要添加获取一些权限,用到了permission_handler,然后在iOS的plist文件里也加了相关的权限配置,但是运行项目,没有权限提示.获取权限状态都是permanentlyDenied.

解决办法:

在podfile里加这些东西:

post_install do |installer|

    installer.pods_project.targets.each do |target|

    target.build_configurations.each do |config|

      # Here are some configurations automatically generated by flutter

      # You can remove unused permissions here

      # for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/develop/permission_handler/ios/Classes/PermissionHandlerEnums.h

      # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'

      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', 

        ## dart: PermissionGroup.bluetooth

        # 'PERMISSION_BLUETOOTH=0'

      ]

    end

  end

end

记得打开需要用到的权限的注释......

上一篇下一篇

猜你喜欢

热点阅读