Update to Scandit Barcode Scanner 4.7

What's new?

In version 4.7 of the Scandit Barcode Scanner, new sets of classes have been introduced that replace the public API of previous versions. To distinguish them from the old API, the new classes and enums are all prefixed with SBS (acronym for Scandit Barcode Scanner).

When updating from a version prior to 4.7, you have to upgrade to the new SBSBarcodePicker API.

Updating from ScanditSDKBarcodePicker to SBSBarcodePicker

This section highlights the differences between the SBSBarcodePicker and ScanditSDKBarcodePicker API and shows how to upgrade existing code.

Scan Settings

The ScanditSDKBarcodePicker contained methods to configure the scanning behavior, e.g. hot spot, enables symbologies, scanning area etc. In the SBSBarcodePicker, these methods no longer exists. Instead the barcode scanner is now configured through a SBSScanSettings instance. The scan settings instance allows you to configure the enabled symbologies and other scanning-related options. The settings do not immediately take effect, but only after applying them to the barcode picker, either when the picker is constructed, or through applyScanSettings:completionHandler: (SBSBarcodePicker).

New Delegates

The ScanditSDKOverlayControllerDelegate has been replaced by two separate delegates: SBSScanDelegate and the SBSOverlayControllerDidCancelDelegate. The former is used for listening to barcode scan events, the latter when the cancel button is pressed on the toolbar. The SBSScanDelegate must be implemented by all applications to handle barcode scanned events.

The key differences between the ScanditSDKOverlayControllerDelegate::scanditSDKOverlayController:didScanBarcode: and barcodePicker:didScan: (SBSScanDelegate-p) callback are:

The following code snippet shows a simple implementation of a SBSScanDelegate callback:

- (void)barcodePicker:(SBSBarcodePicker *)thePicker didScan:(SBSScanSession *)session {
// call stopScanning on the session to immediately stop scanning and close the camera. This
// is the preferred way to stop scanning barcodes from the SBSScanDelegate as it is made sure
// that no new codes are scanned. When calling stopScanning on the picker, another code may be
// scanned before stopScanning has completely stoppen the scanning process.
[session stopScanning];
SBSCode *code = session.newlyRecognizedCodes[0];
// the barcodePicker:didScan delegate method is invoked from a picker-internal queue. To display
// the results in the UI, you need to dispatch to the main queue. Note that it's not allowed
// to use SBSScanSession in the dispatched block as it's only allowed to access the
// SBSScanSession inside the barcodePicker:didScan callback. It is however safe to use results
// returned by session.newlyRecognizedCodes etc.
dispatch_async(dispatch_get_main_queue(), ^{
NSString *symbology = code.symbologyName;
NSString *barcode = code.data;
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:[NSString stringWithFormat:@"Scanned %@", symbology]
message:barcode
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
});
}

Other changes

  • For the new API, the default length of barcodes has been lowered for all variable-length symbologies (Code39, Code93, Code128, Codabar, Interleaved 2 of 5, MSI-Plessey). To scan codes that are longer than the new defaults, you must explicitly enable scanning of longer codes. Take a look at the SBSSymbologySettings::activeSymbolCounts documentation for details on how to do that.
  • The search bar functionality is no longer available when using the SBSBarcodePicker. Instead, you need to implement your own search bar. An example of how this can be done can be found on the Provide a manual input method for 4.7+ page.