BarcodeScanner icon indicating copy to clipboard operation
BarcodeScanner copied to clipboard

Scan on iOS does not send result after flipping camera

Open fretman92 opened this issue 10 years ago • 2 comments

Hello, On iOS, when you click on the flip camera button (to scan with the front camera), the process is cancelled, the JS code receives result.cancelled == 1 and no result is triggered when the actual scan is done. I think this is due to line https://github.com/wildabeast/BarcodeScanner/blob/master/src/ios/CDVBarcodeScanner.mm#L393

Here is the code I'd write to make it work with both camera:

- (void)flipCamera
{
    self.isFlipped = YES;
    self.isFrontCamera = !self.isFrontCamera;
    [self performSelector:@selector(barcodeScanDone) withObject:nil afterDelay:0];
    [self performSelector:@selector(scanBarcode) withObject:nil afterDelay:0.1];
}

Cheers

fretman92 avatar May 20 '15 14:05 fretman92

+1 for this!

PS: is it possible to initialise it to start with the front camera?

pmg103 avatar May 20 '15 14:05 pmg103

+1 this was exactly what I was looking for. Now I can flip the camera and it scans as expected now. This should have been reported as a bug and fixed. Thanks!

ppoisson avatar Aug 25 '15 04:08 ppoisson