Recently, I had my app rejected on the review of App Store connect because it was not requesting the user's permission to access the camera. I found that, testing in different devices, it is requesting the permission on IOS 12, however on IOS 14 it is not, the dialog won't show up and it opens the camera directly. I tried to implement permission_handler to make it work but nothing. By printing the Permission.camera.status I noticed that on IOS 14 is gives me granted, as on IOS 12 it shows denied. Do you guys have any idea how to deal with this situation?
I have already added the files to my info.plist:
<key>NSCameraUsageDescription</key>
<string>Precisamos de acesso a câmera para tirar fotos.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Precisamos de acesso ao microfone para gravar aúdio.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Precisamos de acesso a galeria para buscar a imagens</string>
and the permissions on 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['IPHONEOS_DEPLOYMENT_TARGET'] = '10.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=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.mediaLibrary
# 'PERMISSION_MEDIA_LIBRARY=0',
## dart: PermissionGroup.sensors
#'PERMISSION_SENSORS=0',
## dart: PermissionGroup.bluetooth
#'PERMISSION_BLUETOOTH=0',
## dart: PermissionGroup.appTrackingTransparency
#'PERMISSION_APP_TRACKING_TRANSPARENCY=0',
## dart: PermissionGroup.criticalAlerts
# 'PERMISSION_CRITICAL_ALERTS=0'
]
end
end
end
My implementation when I open the camera:
handleTakePhoto() async {
var status = await Permission.camera.status;
print(status);
if (status.isGranted) {
final PickedFile pickedFile = await picker.getImage(
source: ImageSource.camera, maxHeight: 675, maxWidth: 960);
if (pickedFile != null) {
editImage(pickedFile.path);
}
} else if (status.isDenied) {
final PickedFile pickedFile = await picker.getImage(
source: ImageSource.camera, maxHeight: 675, maxWidth: 960);
if (pickedFile != null) {
editImage(pickedFile.path);
}
} else {
showDialog(
context: context,
builder: (BuildContext context) => CupertinoAlertDialog(
title: Text('Camera Permission'),
content: Text(
'This app needs camera access to take pictures for upload user profile photo'),
actions: <Widget>[
CupertinoDialogAction(
child: Text('Deny'),
onPressed: () => Navigator.of(context).pop(),
),
CupertinoDialogAction(
child: Text('Settings'),
onPressed: () => openAppSettings(),
),
],
));
}
}