phonegap / phonegap-plugin-barcodescanner

cross-platform BarcodeScanner for Cordova / PhoneGap
MIT License
1.27k stars 1.41k forks source link

Need a method to close the scanner screen from the applicaiton #430

Open evernikovskiy opened 7 years ago

evernikovskiy commented 7 years ago

Expected Behaviour

In a case the scanner screen has been opened in a kiosk application by an external user, it would be great to have an API call which allows the application to close the scanner screen from the code (from a timeout callback for example).

Actual Behaviour

The current implementation keeps the scanner screen opened until the user scans a bar code or taps the Cancel button. It makes it impossible for the application to navigate back to the home screen in case the device has been left unattended.

Plugin version

6.0.6

Sample Code that illustrates the problem

// Desired API: cordova.plugins.barcodeScanner.stop();

dodomui commented 7 years ago

I need the same feature also. But failed to implement also.

Tried

  1. $state.reload
  2. $window.location.reload
  3. $state.go
  4. $ionicHistory.goBack

Thousand thanks if anyone got idea how to close the scanner from controller.

SchneMa commented 7 years ago

I need this feature too.

I was unable to find any solution or workaround for this... In my case I want to scan for nfc and barcode at the same time and close the barcodescanner if a nfc tag was found.

Would be great to know if this is even possible or if someone could find a solution for this!

EddyVerbruggen commented 7 years ago

For anyone looking to implement this: I've added support for stopping scanning to the Android library because I needed it in my NativeScript plugin that uses the same native lib. What's missing is similar code like this in the Android plugin Class. On iOS it's probably a matter of dismissing the camera viewcontroller.

jpf0318 commented 7 years ago

I have the same problem,Any solutions ? Especially the android.

fabriciobegalli commented 6 years ago

+1

MontyZhao commented 5 years ago

I have the same issue. But I add a function to fix it. Like this:

javascript: cordova.plugins.barcodeScanner.exit();

java: else if (action.equals(EXIT)){ Intent backIntent = new Intent(cordova.getActivity().getBaseContext(), MainActivity.class); backIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); cordova.startActivityForResult(this, backIntent, REQUEST_CODE); return false; }

mdlauriers commented 5 years ago

@MontyZhao would you mind sharing your JS code for this? It would help me a lot. Thanks!

Or did anyone find a solution for this. It would be very useful for my app.

extreg commented 5 years ago

So, am I correct to assume there is no way cancel, close, exit, or idle close the scanning feature? on both android and ios?

AaryaDevnani commented 4 years ago

did anyone end up figuring it out ?