cordova-barcodescanner-plugin
cordova-barcodescanner-plugin copied to clipboard
Scan as "portrait" instead of "landscape"
Hi,
The scan screen is in landscape mode.
Is it possible to add the option to toggle / set it to portrait mode?
seems to be android specific
I test it on 3 different android versions: 4.4.4, 5.1.1, 6.0.1 all of them rotate the screen to landscape mode.
I know that the error exists in all android version but didn't have time for working on this feature
Would be great if this plugin supports the same configuration props like https://github.com/phonegap/phonegap-plugin-barcodescanner - eg.:
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);
},
{
"preferFrontCamera" : true,
"showFlipCameraButton" : true,
"prompt" : "Place a barcode inside the scan area",
"formats" : "QR_CODE,PDF_417",
"orientation" : "landscape"
}
);
This isn't an enhancement request, this is a bug.
@Krandelbord Have you tried phonegap-plugin-barcodescanner now that this project is discontinued.
Yeah I tried but then the application doesn't start. I assume it phonegap plugins are not compatible with cordova? Is that right ?
I tried it earlier with a fresh project and it worked on my android device. Steps:
$ npm install -g cordova
$ cordova create MyApp
$ cd MyApp
$ cordova platform add android
$ cordova plugin add phonegap-plugin-barcodescanner
At this point paste the example code in index.js
:
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);
},
{
preferFrontCamera : true, // iOS and Android
showFlipCameraButton : true, // iOS and Android
showTorchButton : true, // iOS and Android
torchOn: true, // Android, launch with the torch switched on (if available)
saveHistory: true, // Android, save scan history (default false)
prompt : "Place a barcode inside the scan area", // Android
resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
disableAnimations : true, // iOS
disableSuccessBeep: false // iOS and Android
}
);
Finally, test:
$ cordova run android
Could it be a version mismatch? Are you inserting it into an older project that uses a previous version of cordova?
phonegap-plugin-barcodescanner doesn't seem to work for me either, it does say in the documentation that it "requires phonegap 7.1.0+ "
The latest version of cordova (8.0.0) appears to work fine. What version are you using for your project?
It is getting more offtopic. I'm using cordova 8.0.0 and when I install phonegap-barcode-scanner android-run ends-up with: `* What went wrong: Execution failed for task ':processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
- Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. at ChildProcess.whenDone (/tmp/apc/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) at maybeClose (internal/child_process.js:925:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) (node:29841) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:29841) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. `
I suspect it may be a problem with your build environment.
I just put together a little script that attempts to build a cordova project using the barcodescanner plugin within a clean environment. All files are placed in ~/cordova-demo
and are self-contained. The only user interaction required is when accepting the Android license by pressing y
and enter when prompted.
It downloads the Java 8 JDK, Android SDK tools/build-tools/platform, and Cordova, so make sure you have the bandwidth to accommodate before running the script.
Running the script a second time will just perform the build stage and won't attempt to download anything. Passing along run
as an argument will execute cordova run
instead of cordova build
.