我正在开发一个依赖于几个外部库的 Flutter 应用程序。我不在应用程序中使用相机,但是当我尝试将应用程序提交到 AppStoreConnect 时,Apple 拒绝了我的应用程序,因为他们说我的 Info.plist 文件中没有 NSCameraUsageDescription。由于我没有直接在我的应用程序中使用它,它必须是一个外部库。有没有办法了解请求此权限的库是什么?
问问题
44 次
1 回答
1
运行此命令:
flutter pub deps | grep permission_handler
如果您得到任何输出,则说明正在拉入包。如果这是请求权限的包,则有一种方法可以自定义排除/禁用导入的权限库,在您的Podfile
. 找到这个部分:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
... (you may have additional customizations here)
end
end
并添加一些标志来禁用这些权限,方法是添加一个标志,例如'PERMISSION_CAMERA=0',
要禁用的权限,如下所示:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config| # <-- start adding from here
# 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 adding here
end
end
在上面的示例中,我已经注释掉(因为我的应用程序使用它们)联系人、相机、照片和通知;并禁用所有其他权限。
希望permission_handler是请求权限的包,因为它们很容易修复。
于 2022-01-07T00:03:57.700 回答