Add audio and video authorization check separately
This commit is contained in:
parent
8f2fa1e375
commit
06ad9347a4
|
@ -100,6 +100,8 @@ export default class Camera extends Component {
|
|||
};
|
||||
|
||||
static checkDeviceAuthorizationStatus = CameraManager.checkDeviceAuthorizationStatus;
|
||||
static checkVideoAuthorizationStatus = CameraManager.checkCameraAuthorizationStatus;
|
||||
static checkAudioAuthorizationStatus = CameraManager.checkAudioAuthorizationStatus;
|
||||
|
||||
setNativeProps(props) {
|
||||
this.refs[CAMERA_REF].setNativeProps(props);
|
||||
|
|
|
@ -165,6 +165,26 @@ RCT_EXPORT_METHOD(checkDeviceAuthorizationStatus:(RCTPromiseResolveBlock)resolve
|
|||
}];
|
||||
}
|
||||
|
||||
|
||||
RCT_EXPORT_METHOD(checkCameraAuthorizationStatus:(RCTPromiseResolveBlock)resolve
|
||||
reject:(__unused RCTPromiseRejectBlock)reject) {
|
||||
__block NSString *mediaType = AVMediaTypeVideo;
|
||||
|
||||
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
|
||||
resolve(@(granted));
|
||||
}];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(checkAudioAuthorizationStatus:(RCTPromiseResolveBlock)resolve
|
||||
reject:(__unused RCTPromiseRejectBlock)reject) {
|
||||
__block NSString *mediaType = AVMediaTypeAudio;
|
||||
|
||||
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
|
||||
resolve(@(granted));
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
RCT_EXPORT_METHOD(changeCamera:(NSInteger)camera) {
|
||||
dispatch_async(self.sessionQueue, ^{
|
||||
AVCaptureDevice *currentCaptureDevice = [self.videoCaptureDeviceInput device];
|
||||
|
|
Loading…
Reference in New Issue