У меня есть функция видео встречи в моем приложении 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
Программируем под IOS
1738186195
Anonymous
У меня есть функция видео встречи в моем приложении 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.
Подробнее здесь: [url]https://stackoverflow.com/questions/79397731/permissions-not-working-even-though-they-are-in-info-plist-for-camera-micropho[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия