ios – Permissions not working although they’re in information.plist for Digicam & Microphone

ios – Permissions not working although they’re in information.plist for Digicam & Microphone


I’ve a video assembly characteristic in my Flutter App, earlier than customers begin a gathering they need to test that their Microphone and Digicam permissions are enabled or they cannot be part of the assembly.

      builder: (context) {
        return AlertDialog(
          title: const Textual content("Permissions Required"),
          content material: Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.begin,
            kids: [
              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: <Widget>[
            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();
              },
            ),
          ],
        );
      },
  Future<bool> _getPermissions() async {
    print('Beginning permission checks...');

    attempt {
      // Test present standing first
      ultimate micStatus = await Permission.microphone.standing;
      ultimate cameraStatus = await Permission.digicam.standing;
      print(
          'Preliminary permission standing - Mic: $micStatus, Digicam: $cameraStatus');

      // Replace state based mostly on present standing
      setState(() {
        _isMicEnabled = micStatus.isGranted;
        _isCameraEnabled = cameraStatus.isGranted;
      });

      print('after setState - Mic: $_isMicEnabled, Digicam: $_isCameraEnabled');

      // Request permissions if not already granted
      print('Requesting permissions if wanted...');
      print('going to get mic permissions');
      if (!_isMicEnabled) {
        await _getMicPermissions();
      }
      print('going to get digicam permissions');
      if (!_isCameraEnabled) {
        await _getCameraPermissions();
      }

      // If we nonetheless haven't got permissions after requesting, present 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;
    }
  }

I’ve the mandatory permissions in my information.plist:

    <key>NSCameraUsageDescription</key>
    <string>We'd like entry to your digicam for video calls and capturing photographs</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>We'd like entry to your microphone for voice calls and voice messages</string>

However it all the time tells me that I haven’t got the permissions enabled and I have to open my machine settings, after which when i open the settings these permissions will not be there.

flutter: Beginning permission checks…
flutter: Preliminary permission standing – Mic: PermissionStatus.denied, Digicam: PermissionStatus.denied
flutter: after setState – Mic: false, Digicam: false
flutter: Requesting permissions if wanted…
flutter: going to get mic permissions
flutter: Getting mic permissions
flutter: Present mic standing: PermissionStatus.denied
flutter: after setState for mic – Mic: false, Digicam: false
flutter: Mic permission request outcome: PermissionStatus.permanentlyDenied
flutter: going to get digicam permissions
flutter: Getting digicam permissions
flutter: Present digicam standing: PermissionStatus.denied
flutter: after setState for digicam – Mic: false, Digicam: false
flutter: Digicam permission request outcome: PermissionStatus.permanentlyDenied

I can see it says that my permissions are completely denied however how do i repair this?

For the document I’ve the app deployed on iOS and Android with the identical code and it really works high quality on Android with this code.

I do not suppose there’s something unsuitable with my code however I am unsure what I am lacking that I have to test.

I hate iOS growth and I hate XCode.

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.