#import "RNPermissionHandlerMicrophone.h" @import AVFoundation; @implementation RNPermissionHandlerMicrophone + (NSArray * _Nonnull)usageDescriptionKeys { return @[@"NSMicrophoneUsageDescription"]; } + (NSString * _Nonnull)handlerUniqueId { return @"ios.permission.MICROPHONE"; } - (void)checkWithResolver:(void (^ _Nonnull)(RNPermissionStatus))resolve rejecter:(void (__unused ^ _Nonnull)(NSError * _Nonnull))reject { switch ([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio]) { case AVAuthorizationStatusNotDetermined: return resolve(RNPermissionStatusNotDetermined); case AVAuthorizationStatusRestricted: return resolve(RNPermissionStatusRestricted); case AVAuthorizationStatusDenied: return resolve(RNPermissionStatusDenied); case AVAuthorizationStatusAuthorized: return resolve(RNPermissionStatusAuthorized); } } - (void)requestWithResolver:(void (^ _Nonnull)(RNPermissionStatus))resolve rejecter:(void (^ _Nonnull)(NSError * _Nonnull))reject { [AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(__unused BOOL granted) { [self checkWithResolver:resolve rejecter:reject]; }]; } @end