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] )