iPhone相机和图库权限请求问题

问题描述 投票:0回答:1

我正在创建一个 flutter ios 应用程序,我需要相机或照片权限

    Future<bool> _checkAndRequestPermission(Permission permission) async {
    var status = false;
    if (Platform.isAndroid) {
      final AndroidDeviceInfo deviceInfo = await DeviceInfoPlugin().androidInfo;
      final int sdkInt = deviceInfo.version.sdkInt ?? 0;
      status =
          sdkInt > 32 ? await permissionPhotos() : await permissionStorage();
    } else {
      print('we are on iphone emulator');
      var status = await permission.status;
      if (status.isDenied || status.isRestricted) {
        status = await permission
            .request(); // Request permission if denied or restricted
      }

      if (status.isPermanentlyDenied) {
        openAppSettings(); // Direct user to settings if permanently denied
        return false;
      }
      print('return here: ${status.isGranted}');
      return status.isGranted;
    }

    return Future<bool>.value(status);
  }

这是我的代码,如果权限被拒绝,我将尝试请求权限 我还更新了 info.plist 是的,这段代码几天前工作正常,但现在它首先给出权限状态为拒绝,然后在没有请求权限的情况下它说永久拒绝

我尝试了很多次还是没有结果

虽然它在安卓上运行良好

出了什么问题?

有人可以帮忙吗..

iphone flutter dart permissions
1个回答
0
投票

现在已经解决了 我更新了我的 Podfile 并做了以下事情然后繁荣..

    post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
            config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
               '$(inherited)',

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

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

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

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

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

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

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

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

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

               ## dart: PermissionGroup.appTrackingTransparency
                ##'PERMISSION_APP_TRACKING_TRANSPARENCY=1',

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

               ## dart: PermissionGroup.sensors
               #'PERMISSION_SENSORS=0'
             ]
    end
  end
end
© www.soinside.com 2019 - 2024. All rights reserved.