macosmauisipmaui-blazor

Grant Permission Of Microphone & Camera In MAC Catalyst In .NET MAUI Blazor Component App


I have one application which is developed in .NET MAUI Blazor Component.

It holds a SIP/VOIP functionalities.

In this application, There is functionality of video calling. So when I am running this app on windows, Its working fine and pop-up for permission of mic and camera is showing up.

enter image description here

But when I am trying to running same application on MAC Catalyst, The pop-up for permission of mic and camera is not showing up there.

I have tried below stuff to show above popup in MAC Catalyst. But I was not able to see popup still.

if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  navigator.mediaDevices.getUserMedia({ audio: true, video: true })
    .then(function(stream) {
    })
    .catch(function(error) {
    });
} else {
}
 

So, My question is... How can I show this pop-up in MAC Catalyst. If there is not any way to show up this, Then how can I programmatically grant permission of mic & camera in MAC Catalyst.


Solution

  • Yes, we should first add NSCameraUsageDescription and NSMicrophoneUsageDescription.

    Also, please add the AVCaptureDevice.RequestAccessForMediaType to show the prompt. Consider the following code:

    //if want to show microphone prompt, you could use AVAuthorizationMediaType.Audio
    AVCaptureDevice.RequestAccessForMediaType (AVAuthorizationMediaType.Video, (bool isPermissionGranted) => 
    {                                
        if(isPermissionGranted)
        {
      
        }
        else
        {
      
        }
    });
    

    Then the prompt should show. For more info, you could refer to requestAccessForMediaType:completionHandler:

    By the way, the prompt will show at the first time after app is installed. The os will remember the user's response so subsequent uses of the capture system don’t cause the prompt to appear again.

    Hope it works. enter image description here