Table of contents
Swift
Objective-C

How to Initialize Customized Templates

Using a template file is one of the quickest ways to improve BarcodeScanner performance. A template file is a JSON file (or JSON string) that contains a set of algorithm parameter settings. Contact us to get a customized template for your scanner.

Preparation

Add a Templates folder under your project’s assets directory at src\main\assets\Templates. Put your JSON file in the Templates folder. Here, we use ReadQRCode.json as an example.

initSettings

init settings

Initialize with Foundational APIs

  • Objective-C
  • Swift
  1. NSError *error = nil;
    [self.cvr initSettingsFromFile:@"ReadQRCodes.json" error:&error];
    
  2. do {
       try cvr.initSettingsFromFile("ReadQRCodes.json")
    } catch {
       print("initSettingsFromFile error:\(error.localizedDescription)")
    }
    

Initialize with BarcodeScanner APIs

Specify the template file with setTemplateFile.

  • Objective-C
  • Swift
  1. DSBarcodeScannerConfig *config = [[DSBarcodeScannerConfig alloc] init];
    config.templateFile = @"ReadQRCodes.json";
    
  2. let config = BarcodeScannerConfig()
    config.templateFile = "ReadQRCodes.json"
    

Related APIs

This page is compatible for: