L
L
Leonid2016-10-12 12:00:25
Mobile development
Leonid, 2016-10-12 12:00:25

The BarcodeScanner plugin function in the PhoneGap application for scanning a QR code does not return anything - why?

There is a PhoneGap mobile application that is supposed to use a QR code scanner. I use the plugin: BarcodeScanner, I do everything according to the instructions.
Added to config.xml:

<plugin name="com.phonegap.plugins.barcodescanner" spec="2.0.0" source="pgb" />

Well, the actual js code for scanning:
cordova.plugins.barcodeScanner.scan(
      function (result) {
          alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
      }, 
      function (error) {
          alert("Scanning failed: " + error);
      }
   );

As a result, when this code is called, the camera window really opens, the QR code is scanned, but then nothing happens, that is, after scanning, there are no alerts.
I run tests on iPhone5, in its system log the following is written about my application:
Oct 11 20:18:49 iPhone MyApp[4669] <Warning>: WARNING: -[<AVCaptureVideoPreviewLayer: 0x15de5610> isOrientationSupported] is deprecated.  Please use AVCaptureConnection's -isVideoOrientationSupported
Oct 11 20:18:49 iPhone MyApp[4669] <Warning>: WARNING: -[<AVCaptureVideoPreviewLayer: 0x15de5610> setOrientation:] is deprecated.  Please use AVCaptureConnection's -setVideoOrientation:
Oct 11 20:18:49 iPhone MyApp[4669] <Warning>: WARNING: -[<AVCaptureVideoPreviewLayer: 0x15de5610> setOrientation:] is deprecated.  Please use AVCaptureConnection's -setVideoOrientation:
Oct 11 20:18:58 iPhone kernel[0] <Notice>: AppleH4CamIn::ISP_FlushInactiveDARTMappings: 0x00000000
Oct 11 20:18:58 iPhone MyApp[4669] <Error>: -[CDVPluginResult toSuccessCallbackString:]: unrecognized selector sent to instance 0x15d28ad0

What's wrong? Where to dig?
ps: if you press the Cancel button in the scanner, the application closes (crashes).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Leonid, 2016-10-15
@easycode

The issue was resolved using a more recent version of the plugin 2.2.0:
as well as connecting the js-file of the plugin in the index.html file:

<script type="text/javascript" src="barcodescanner.js"></script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question