There is a PhoneGap mobile application in which you intend to use a QR code scanner. I use the plugin: BarcodeScanner , I do everything according to the instructions:

Added in config.xml:

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

Well, actually js-code scan:

  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, well, then nothing happens, that is, after scanning no alerts.

I conduct tests on iPhone5, in its system log about my application the following is written:

 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?

  • one
    Well, as you can see, you do not have the toSuccessCallbackString function. Either this is a delegate method and you need to write it, or if this is a library method, apparently some part of it is not connected - Max Mikheyenko
  • one
    write issue on githaba, they will answer you there faster - Max Mikheyenko

1 answer 1

The issue was resolved using a more recent version of the plugin 2.2.0:

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

as well as connecting the js-file of the plugin in the index.html file:

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