From 35c6fca5c3b2385574fb31ff1dfa8b9b0467b7ba Mon Sep 17 00:00:00 2001 From: Evgeni Silman Date: Mon, 4 Mar 2019 15:29:20 +0200 Subject: [PATCH] Added setter of onReadCode. --- ios/lib/ReactNativeCameraKit/CKCamera.m | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ios/lib/ReactNativeCameraKit/CKCamera.m b/ios/lib/ReactNativeCameraKit/CKCamera.m index f68c152..a89d103 100644 --- a/ios/lib/ReactNativeCameraKit/CKCamera.m +++ b/ios/lib/ReactNativeCameraKit/CKCamera.m @@ -297,18 +297,23 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{ else { self.setupResult = CKSetupResultSessionConfigurationFailed; } - if (self.onReadCode) {//TODO check if qrcode mode is on - self.metadataOutput = [[AVCaptureMetadataOutput alloc] init]; - [self.session addOutput:self.metadataOutput]; - [self.metadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()]; - [self.metadataOutput setMetadataObjectTypes:[self.metadataOutput availableMetadataObjectTypes]]; - } - [self.session commitConfiguration]; } ); } +-(void)setOnReadCode:(RCTDirectEventBlock)onReadCode +{ + _onReadCode = onReadCode; + if (self.onReadCode) {//TODO check if qrcode mode is on + self.metadataOutput = [[AVCaptureMetadataOutput alloc] init]; + [self.session addOutput:self.metadataOutput]; + [self.metadataOutput setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()]; + [self.metadataOutput setMetadataObjectTypes:[self.metadataOutput availableMetadataObjectTypes]]; + } + [self.session commitConfiguration]; +} + -(void)handleCameraPermission { switch ( [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo] )