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

Add continuous scanning support #122

Closed
SunboX opened this issue Dec 7, 2015 · 9 comments
Closed

Add continuous scanning support #122

SunboX opened this issue Dec 7, 2015 · 9 comments

Comments

@SunboX
Copy link
Contributor

SunboX commented Dec 7, 2015

Please add support for continuous scanning, so that the barcode scanner does not close after a successful scan.

This could work like this:

var scans = 0,
    messageTimeout;
cordova.plugins.barcodeScanner.continuousScan(
    function(result) {
        // This method will get triggered for every barcode found (continuously)
        clearTimeout(messageTimeout);
        cordova.plugins.barcodeScanner.message('Product found');
        setTimeout(function() {
            messageTimeout = cordova.plugins.barcodeScanner.message(null);
        }, 1000);
        if (++scans === 10) {
            cordova.plugins.barcodeScanner.hide();
        }
    },
    function(error) {
        clearTimeout(messageTimeout);
        cordova.plugins.barcodeScanner.message('Scanning failed: ' + error);
        setTimeout(function() {
            messageTimeout = cordova.plugins.barcodeScanner.message(null);
        }, 1000);
    }
);
@elewin
Copy link

elewin commented May 16, 2016

A work around I have used is to recursively call the scan method after every success until the user clicks cancel

@Giriton
Copy link

Giriton commented Jul 8, 2016

I would also welcome this feature. It could for example "scan until user clicks done/back button" and then return results in array.. What do you think?

@abcd-ca
Copy link

abcd-ca commented Aug 5, 2016

@Giriton I have just implemented such a workaround. I don't think it's quite as fast or elegant as just leaving the camera open but it does work. On iOS 9.3, the done button returns me to my Web UI, same with a Google Nexus 4 running Android 5.x. My "Samsung Galaxy Tab A" has a weird thing where if I tap the hardware back button to cancel, it closes the camera UI but also triggers a back call in the web ui, in my case either navigating me backwards or dismissing an open modal. So, I need to find a way for the back button, when in the camera UI, to not propagate to the web ui after dismissing the camera UI.

@carol-braileanu
Copy link

I agree, continuous scanning is indeed needed for real-world scanning apps. Calling the scan() method recursively works, but it has some lag to it and it decreases performance. Any update on this issue?

@EddyVerbruggen
Copy link
Collaborator

If anyone is willing to implement it: on Android we're using the same library as the NativeScript plugin which I've added continuous scan support to already. All required changes to the native library are already in place, so it should be relatively straightforward to add this to the Cordova plugin as well.

On iOS the NativeScript plugin uses my custom library, not the same as the one used in the Cordova plugin, so it may be a little harder.

@fttx
Copy link
Contributor

fttx commented Jul 2, 2017

+1

calling scan() recursively isn't a great solution

@macdonst
Copy link
Member

Duplicate of #69

@houssem2101
Copy link

+1

calling scan() recursively has some lag

@lock
Copy link

lock bot commented Jun 8, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

10 participants