Problems using the Scandit component

JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai

I am trying out the Scandit component, and I have followed the examples to get it working for it's basic purpose. However I am running into different issues trying to use it to display some results page after scanning. I am not sure how it is meant to be handled, balancing the StopScanning/StartScanning etc.

I have my code like this:

// ViewDidLoad of my ScannerController
//
// Setup the barcode scanner
picker = new ScanditSDK.SIBarcodePicker ("MyActualAPIKeyIsHere");
picker.OverlayController.Delegate = new ScannerDelegate (this);
picker.OverlayController.ShowToolBar (true);

// Display the Scandit user interface
PresentViewController (picker, true, null);
picker.StartScanning ();


// ScannerDelegate class methods
//
public override void DidScanBarcode (SIOverlayController overlayController, NSDictionary barcode) {
// perform actions after a barcode was scanned
parent.StopScanning ();

string code = barcode ["barcode"].ToString();
string symbol = barcode ["symbology"].ToString();

    // Here I would like to hit a web service and load a new screen
    LoadSomeStuff(barcode).ContinueWith(_ => {
        // parent is a reference to my ScannerController.
        parent.ShowDetailsOfSomeStuff();
    });

}

I was thinking that I should call picker.StopScanning(); in my LoadSomeStuff() method so that it is not continuing to read barcodes and firing this event again while the person holds the phone over a label. However, this seems to work the first time but not concurrent times. Calling stop and then start doesn't always work how I think it should, and on top of that I sometimes get a duplicate cancel button in the toolbar doing this. I think I am handling something wrong, so I would like some help on a more complete example of how to use this component properly. Any suggestions are greatly welcome on how you might of handled this!

Thanks in advance!

Posts

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai

    Here is a simple example of what I am doing.

    picker.OverlayController.DidScanBarcode += (sender, e) => {
        picker.StopScanning();
        DismissViewController(true, null);
    };
    
    scanButton = new UIBarButtonItem ("Scan", UIBarButtonItemStyle.Plain, null);
    scanButton.Clicked += (sender, e) => {
        PresentViewController(picker, true, null);
        picker.StartScanning();
    };
    

    Doing this, the second scan will dismiss the controller, but when you relaunch it a third time, it no longer is scanning.

  • KymPhillpottsKymPhillpotts AUMember, University ✭✭

    Hi John,

    Did you get any further information from this. I am sometimes seeing the duplicate Cancel button as well. but not sure how to deal with it, or what the cause is.

    Cheers,
    Kym

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai

    @KymPhillpotts,

    No, I did not really find a solution for my problems. The example projects are all obj-c and I can't seem to figure out how to translate them very well to using them in my xamarin project. It also seems not all the properties are available in the component, I was not able to find some that matched the definitions in the header files. Documentation is slim on this one...

Sign In or Register to comment.