Deprecation warning

Please note that this is outdated documentation for an older release of the Scandit Barcode Scanner SDK.

We encourage you to migrate to 6.x and take advantage of our latest / advanced features and improved performance.

You'll find the updated documentation at: Data Capture SDK Documentation for iOS

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 two options:

  • continue to use the ScanditSDKBarcodePicker and ScanditSDKOverlayController classes. Improvements to the barcode recognition engine (performance, recognition rates) will also be available when using the ScanditSDKBarcodePicker. However, new features that require additions to the API will only be added to the SBSBarcodePicker. Thus if you need any of these new features, you will have to update to use the new classes. When you continue to use the ScanditSDKBarcodePicker you will only have to update the imports statement to use the headers contained in the ScanditBarcodeScanner framework. For example, you need to change
    1 #import "ScanditSDKBarcodePicker.h"
    to
    1 #import <ScanditBarcodeScanner/ScanditSDKBarcodePicker.h>
  • upgrade to the new SBSBarcodePicker API (see below).

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 scanditSDKOverlayController:didScanBarcode: (ScanditSDKOverlayControllerDelegate-p) 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 objectAtIndex: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.symbologyString;
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 Providing a manual input method for 4.7+ page.