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

Accepted Reply

Found it.

Replies

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

Found it.