Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ class AROverlayBarcodeScannerUI2ViewController: UIViewController {
super.viewDidLoad()

// Start scanning here. Usually this is an action triggered by some button or menu.
self.startScanning()
Task {
await self.startScanning()
}
}

func startScanning() {
func startScanning() async {

// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerScreenConfiguration()
Expand All @@ -36,16 +38,29 @@ class AROverlayBarcodeScannerUI2ViewController: UIViewController {
configuration.useCase = usecase

// Create and set an array of accepted barcode formats.
configuration.scannerConfiguration.barcodeFormats = SBSDKBarcodeFormats.twod
configuration.scannerConfiguration.setBarcodeFormats(SBSDKBarcodeFormats.twod)

// Present the view controller modally.
SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration) { controller, cancelled, error, result in
do {
let result = try await SBSDKUI2BarcodeScannerViewController.present(on: self, configuration: configuration)

// Completion handler to process the result.
// The `cancelled` parameter indicates if the cancel button was tapped.
// Handle the result.
result.items.forEach { barcodeItem in
// e.g
print(barcodeItem.count)
print(barcodeItem.barcode.format.name)
print(barcodeItem.barcode.text)
print(barcodeItem.barcode.textWithExtension)
// Check out other available properties in `SBSDKBarcodeItem`.
}
print(result.selectedZoomFactor)

} catch SBSDKError.operationCanceled {
print("The operation was cancelled before completion or by the user")

controller.presentingViewController?.dismiss(animated: true)
} catch {
// Any other error
print("Error scanning barcode: \(error.localizedDescription)")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ class ActionBarConfigurationUI2ViewController: UIViewController {
super.viewDidLoad()

// Start scanning here. Usually this is an action triggered by some button or menu.
self.startScanning()
Task {
await self.startScanning()
}
}

func startScanning() {
func startScanning() async {

// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerScreenConfiguration()
Expand Down Expand Up @@ -51,16 +53,29 @@ class ActionBarConfigurationUI2ViewController: UIViewController {
actionBar.flipCameraButton.foregroundColor = SBSDKUI2Color(colorString: "#FFFFFF")

// Create and set an array of accepted barcode formats.
configuration.scannerConfiguration.barcodeFormats = SBSDKBarcodeFormats.twod
configuration.scannerConfiguration.setBarcodeFormats(SBSDKBarcodeFormats.twod)

// Present the view controller modally.
SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration) { controller, cancelled, error, result in
do {
let result = try await SBSDKUI2BarcodeScannerViewController.present(on: self, configuration: configuration)

// Completion handler to process the result.
// The `cancelled` parameter indicates if the cancel button was tapped.
// Handle the result.
result.items.forEach { barcodeItem in
// e.g
print(barcodeItem.count)
print(barcodeItem.barcode.format.name)
print(barcodeItem.barcode.text)
print(barcodeItem.barcode.textWithExtension)
// Check out other available properties in `SBSDKBarcodeItem`.
}
print(result.selectedZoomFactor)

} catch SBSDKError.operationCanceled {
print("The operation was cancelled before completion or by the user")

controller.presentingViewController?.dismiss(animated: true)
} catch {
// Any other error
print("Error scanning barcode: \(error.localizedDescription)")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ class FindAndPickBarcodeScannerUI2ViewController: UIViewController {
super.viewDidLoad()

// Start scanning here. Usually this is an action triggered by some button or menu.
self.startScanning()
Task {
await self.startScanning()
}
}

func startScanning() {
func startScanning() async {

// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerScreenConfiguration()
Expand Down Expand Up @@ -53,13 +55,26 @@ class FindAndPickBarcodeScannerUI2ViewController: UIViewController {
configuration.useCase = usecase

// Present the view controller modally.
SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration) { controller, cancelled, error, result in
do {
let result = try await SBSDKUI2BarcodeScannerViewController.present(on: self, configuration: configuration)

// Completion handler to process the result.
// The `cancelled` parameter indicates if the cancel button was tapped.
// Handle the result.
result.items.forEach { barcodeItem in
// e.g
print(barcodeItem.count)
print(barcodeItem.barcode.format.name)
print(barcodeItem.barcode.text)
print(barcodeItem.barcode.textWithExtension)
// Check out other available properties in `SBSDKBarcodeItem`.
}
print(result.selectedZoomFactor)

} catch SBSDKError.operationCanceled {
print("The operation was cancelled before completion or by the user")

controller.presentingViewController?.dismiss(animated: true)
} catch {
// Any other error
print("Error scanning barcode: \(error.localizedDescription)")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@ class BarcodeGettingStartedUI2ViewController: UIViewController {

func launchRTUUIv2Scanner() {

// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerScreenConfiguration()

// Present the scanner view controller modally on this view controller.
SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration) { controller, cancelled, error, result in

// Completion handler to process the result.
// The `cancelled` parameter indicates if the cancel button was tapped.
Task {
// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerScreenConfiguration()

controller.presentingViewController?.dismiss(animated: true)
// Present the view controller modally.
do {
let result = try await SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration)
// Process the result as needed.

} catch SBSDKError.operationCanceled {
print("The operation was cancelled before completion or by the user")

} catch {
// Any other error
print("Error scanning barcode: \(error.localizedDescription)")
}
}
}

func handleScanResults() {

// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerScreenConfiguration()

// Present the scanner view controller modally on this view controller.
SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration) { controller, cancelled, error, result in

if cancelled {

// Indicates that the cancel button was tapped.
controller.presentingViewController?.dismiss(animated: true)

} else if let items = result?.items {

Task {
// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerScreenConfiguration()

// Present the view controller modally.
do {
let result = try await SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration)
// Process result
items.forEach({ item in
result.items.forEach({ item in

print("Barcode Identity String: \(item.barcode.identityString)")
print("Scan count: \(item.count)")
Expand Down Expand Up @@ -78,9 +78,15 @@ class BarcodeGettingStartedUI2ViewController: UIViewController {
print("\n" + "\(field.type.displayText ?? ""): \(field.value?.text ?? "")")
})
}

})
}
catch SBSDKError.operationCanceled {
print("The operation was cancelled before completion or by the user")

} catch {
// Any other error
print("Error scanning barcode: \(error.localizedDescription)")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ class InfoMappingBarcodeScannerUI2ViewController: UIViewController {
super.viewDidLoad()

// Start scanning here. Usually this is an action triggered by some button or menu.
self.startScanning()
Task {
await self.startScanning()
}
}

func startScanning() {
func startScanning() async {

// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerScreenConfiguration()
Expand Down Expand Up @@ -59,16 +61,29 @@ class InfoMappingBarcodeScannerUI2ViewController: UIViewController {
configuration.useCase = usecase

// Create and set an array of accepted barcode formats.
configuration.scannerConfiguration.barcodeFormats = SBSDKBarcodeFormats.twod
configuration.scannerConfiguration.setBarcodeFormats(SBSDKBarcodeFormats.twod)

// Present the view controller modally.
SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration) { controller, cancelled, error, result in
do {
let result = try await SBSDKUI2BarcodeScannerViewController.present(on: self, configuration: configuration)

// Completion handler to process the result.
// The `cancelled` parameter indicates if the cancel button was tapped.
// Handle the result.
result.items.forEach { barcodeItem in
// e.g
print(barcodeItem.count)
print(barcodeItem.barcode.format.name)
print(barcodeItem.barcode.text)
print(barcodeItem.barcode.textWithExtension)
// Check out other available properties in `SBSDKBarcodeItem`.
}
print(result.selectedZoomFactor)

} catch SBSDKError.operationCanceled {
print("The operation was cancelled before completion or by the user")

controller.presentingViewController?.dismiss(animated: true)
} catch {
// Any other error
print("Error scanning barcode: \(error.localizedDescription)")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ class BarcodeLocalizationUI2ViewController: UIViewController {
super.viewDidLoad()

// Start scanning here. Usually this is an action triggered by some button or menu.
self.startScanning()
Task {
await self.startScanning()
}
}

func startScanning() {
func startScanning() async {

// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerScreenConfiguration()
Expand All @@ -32,13 +34,26 @@ class BarcodeLocalizationUI2ViewController: UIViewController {
configuration.localization = localization

// Present the view controller modally.
SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration) { controller, cancelled, error, result in
do {
let result = try await SBSDKUI2BarcodeScannerViewController.present(on: self, configuration: configuration)

// Completion handler to process the result.
// The `cancelled` parameter indicates if the cancel button was tapped.
// Handle the result.
result.items.forEach { barcodeItem in
// e.g
print(barcodeItem.count)
print(barcodeItem.barcode.format.name)
print(barcodeItem.barcode.text)
print(barcodeItem.barcode.textWithExtension)
// Check out other available properties in `SBSDKBarcodeItem`.
}
print(result.selectedZoomFactor)

} catch SBSDKError.operationCanceled {
print("The operation was cancelled before completion or by the user")

controller.presentingViewController?.dismiss(animated: true)
} catch {
// Any other error
print("Error scanning barcode: \(error.localizedDescription)")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@ class MultipleBarcodeScannerUI2ViewController: UIViewController {
super.viewDidLoad()

// Start scanning here. Usually this is an action triggered by some button or menu.
self.startScanning()
Task {
await self.startScanning()
}
}

func startScanning() {
func startScanning() async {

// Create the default configuration object.
let configuration = SBSDKUI2BarcodeScannerScreenConfiguration()

// Initialize the multi scan usecase.
let multiUsecase = SBSDKUI2MultipleScanningMode()

// Set the counting repeat delay.
multiUsecase.countingRepeatDelay = 1000

// Set the counting mode.
multiUsecase.mode = .counting
// Set the unique mode.
multiUsecase.mode = .unique

// Set the sheet mode of the barcodes preview.
multiUsecase.sheet.mode = .collapsedSheet
Expand All @@ -48,16 +47,29 @@ class MultipleBarcodeScannerUI2ViewController: UIViewController {
configuration.useCase = multiUsecase

// Create and set an array of accepted barcode formats.
configuration.scannerConfiguration.barcodeFormats = SBSDKBarcodeFormats.twod
configuration.scannerConfiguration.setBarcodeFormats(SBSDKBarcodeFormats.twod)

// Present the view controller modally.
SBSDKUI2BarcodeScannerViewController.present(on: self,
configuration: configuration) { controller, cancelled, error, result in
do {
let result = try await SBSDKUI2BarcodeScannerViewController.present(on: self, configuration: configuration)

// Completion handler to process the result.
// The `cancelled` parameter indicates if the cancel button was tapped.
// Handle the result.
result.items.forEach { barcodeItem in
// e.g
print(barcodeItem.count)
print(barcodeItem.barcode.format.name)
print(barcodeItem.barcode.text)
print(barcodeItem.barcode.textWithExtension)
// Check out other available properties in `SBSDKBarcodeItem`.
}
print(result.selectedZoomFactor)

} catch SBSDKError.operationCanceled {
print("The operation was cancelled before completion or by the user")

controller.presentingViewController?.dismiss(animated: true)
} catch {
// Any other error
print("Error scanning barcode: \(error.localizedDescription)")
}
}
}
Loading