Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

iOS - tracking of disappearing event when swiping out the scanning dialog #881

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/ios/CDVBarcodeScanner.mm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ @interface CDVbcsProcessor : NSObject <AVCaptureMetadataOutputObjectsDelegate> {
@property (nonatomic) BOOL isFlipped;
@property (nonatomic) BOOL isTransitionAnimated;
@property (nonatomic) BOOL isSuccessBeepEnabled;
@property (nonatomic) BOOL isSuccess;
@property (nonatomic) BOOL isCancelled;



- (id)initWithPlugin:(CDVBarcodeScanner*)plugin callback:(NSString*)callback parentViewController:(UIViewController*)parentViewController alterateOverlayXib:(NSString *)alternateXib;
Expand Down Expand Up @@ -417,6 +420,9 @@ - (BOOL)checkResult:(NSString *)result {
//--------------------------------------------------------------------------
- (void)barcodeScanSucceeded:(NSString*)text format:(NSString*)format {
dispatch_sync(dispatch_get_main_queue(), ^{

self.isSuccess = true;

if (self.isSuccessBeepEnabled) {
AudioServicesPlaySystemSound(_soundFileObject);
}
Expand Down Expand Up @@ -771,6 +777,14 @@ - (void)viewWillAppear:(BOOL)animated {
self.processor.previewLayer.frame = self.view.bounds;
}

- (void)viewWillDisappear:(BOOL)animated{
if ( !(self.processor.isCancelled) && !(self.processor.isSuccess) )
{
[self.processor performSelector:@selector(barcodeScanCancelled) withObject:nil afterDelay:0];
}
}


//--------------------------------------------------------------------------
- (void)viewDidAppear:(BOOL)animated {
// setup capture preview layer
Expand Down Expand Up @@ -817,6 +831,7 @@ - (IBAction)shutterButtonPressed {

//--------------------------------------------------------------------------
- (IBAction)cancelButtonPressed:(id)sender {
self.processor.isCancelled = true;
[self.processor performSelector:@selector(barcodeScanCancelled) withObject:nil afterDelay:0];
}

Expand Down