Add audio and video authorization check separately

This commit is contained in:
Robin Breuker 2016-03-17 15:07:39 +01:00
parent 8f2fa1e375
commit 06ad9347a4
2 changed files with 22 additions and 0 deletions

View File

@ -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);

View File

@ -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];