У меня есть функция видео встречи в моем приложении Flutter, прежде чем пользователи начнут встречу, они должны проверить, что их разрешения микрофона и камеры включены или они не могут присоединиться к встрече. < /p>
builder: (context) {
return AlertDialog(
title: const Text("Permissions Required"),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"The following permissions are needed for video calls:"),
if (!micEnabled)
Text(
"• Microphone: ${!micEnabled ? 'Not granted' : 'Granted'}"),
if (!cameraEnabled)
Text("• Camera: ${!cameraEnabled ? 'Not granted' : 'Granted'}"),
const SizedBox(height: 8),
const Text(
"Please grant these permissions in your device settings to continue.",
style: TextStyle(fontSize: 12),
),
],
),
actions: [
TextButton(
child: const Text("Try Again"),
onPressed: () {
Navigator.of(context).pop();
_getPermissions();
},
),
TextButton(
child: const Text("Open Settings"),
onPressed: () async {
Navigator.of(context).pop();
await openAppSettings();
},
),
],
);
},
< /code>
Future _getPermissions() async {
print('Starting permission checks...');
try {
// Check current status first
final micStatus = await Permission.microphone.status;
final cameraStatus = await Permission.camera.status;
print(
'Initial permission status - Mic: $micStatus, Camera: $cameraStatus');
// Update state based on current status
setState(() {
_isMicEnabled = micStatus.isGranted;
_isCameraEnabled = cameraStatus.isGranted;
});
print('after setState - Mic: $_isMicEnabled, Camera: $_isCameraEnabled');
// Request permissions if not already granted
print('Requesting permissions if needed...');
print('going to get mic permissions');
if (!_isMicEnabled) {
await _getMicPermissions();
}
print('going to get camera permissions');
if (!_isCameraEnabled) {
await _getCameraPermissions();
}
// If we still don't have permissions after requesting, show settings dialog
if (!_isMicEnabled || !_isCameraEnabled) {
if (context.mounted) {
_showPermissionDeniedDialog(context, _isMicEnabled, _isCameraEnabled);
}
return false;
}
return true;
} catch (e) {
print('Error getting permissions: $e');
return false;
}
}
< /code>
I have the necessary permissions in my info.plist:
NSCameraUsageDescription
We need access to your camera for video calls and capturing photos
NSMicrophoneUsageDescription
We need access to your microphone for voice calls and voice messages
< /code>
But it always tells me that I don't have the permissions enabled and I need to open my device settings, and then when i open the settings those permissions are not there.
flutter: Starting permission checks...
flutter: Initial permission status - Mic: PermissionStatus.denied, Camera: PermissionStatus.denied
flutter: after setState - Mic: false, Camera: false
flutter: Requesting permissions if needed...
flutter: going to get mic permissions
flutter: Getting mic permissions
flutter: Current mic status: PermissionStatus.denied
flutter: after setState for mic - Mic: false, Camera: false
flutter: Mic permission request result: PermissionStatus.permanentlyDenied
flutter: going to get camera permissions
flutter: Getting camera permissions
flutter: Current camera status: PermissionStatus.denied
flutter: after setState for camera - Mic: false, Camera: false
flutter: Camera permission request result: PermissionStatus.permanentlyDenied
I can see it says that my permissions are permanently denied but how do i fix this?
For the record I have the app deployed on iOS and Android with the same code and it works fine on Android with this code.
I don't think there's anything wrong with my code but I'm not sure what I'm missing that I need to check.
I hate iOS development and I hate XCode.
Подробнее здесь: https://stackoverflow.com/questions/793 ... a-micropho
Разрешения не работают, даже если они находятся в Info.Plist для камеры и микрофона ⇐ IOS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Разрешения не работают, даже если они находятся в Info.Plist для камеры и микрофона
Anonymous » » в форуме IOS - 0 Ответы
- 19 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Как написать хорошее описание разрешения приложения для ios в info.plist [закрыто]
Anonymous » » в форуме IOS - 0 Ответы
- 53 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Unity запрашивает разрешения только для микрофона и камеры, но игнорирует остальные
Anonymous » » в форуме Android - 0 Ответы
- 26 Просмотры
-
Последнее сообщение Anonymous
-