AVCaptureDevice requestAccessForMediaType

Hi,


MacOS 10.15.2


<key>NSMicrophoneUsageDescription</key>

<string>Record audio!</string>


This crashes.

[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted)

{

if (granted)

{

// [self setupCaptureSession];

}

}];


Also,

Preferences->Security & Privacy - Microphone has no reference to the Voice Memo app even after using it and allowing access to the mic.


Any help appreciated.

Paul

Answered by dumbbunny in 400873022

Found it.

Hi,

MacOS 10.15.2


<key>NSMicrophoneUsageDescription</key>

<string>Record audio!</string>


This works in a swift project:


AVCaptureDevice.requestAccess(for: .audio) { granted in

if granted {

//self.setupCaptureSession()

}

}


This doesn't work in an ObjectiveC project: (Thread 6: signal SIGABRT)

[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted)

{

if (granted)

{

// [self setupCaptureSession];

}

}];


What am I not doing correcty or forgot to include?


Thanks, paul

Accepted Answer

Found it.

AVCaptureDevice requestAccessForMediaType
 
 
Q