SparkScan View

Defined in framework ScanditBarcodeCapture

enum SparkScanScanningBehavior

Added in version 6.15.0

The capture mode type of the SparkScanView.

single

Added in version 6.15.0

Barcode capturing session is stopped after each scan.

continuous

Added in version 6.15.0

Keeps the barcode capturing session active for longer time.

enum SparkScanPreviewBehavior

Added in version 6.23.0

The preview behavior type of the SparkScanView.

`default`

Added in version 6.23.0

After a scan with scanning behavior SparkScanScanningBehavior.single, or stopping scanning with scanning behavior SparkScanScanningBehavior.continuous, camera moves to standby state and preview is hidden for maximum efficiency.

persistent

Added in version 6.23.0

After a scan with scanning behavior SparkScanScanningBehavior.single, or stopping scanning with scanning behavior SparkScanScanningBehavior.continuous, camera stays active and preview is visible for maximum precision.

enum SparkScanViewHandMode

Added in version 6.15.0

The hand mode type of the SparkScanView.

Deprecated since version 7.0: Hand mode is no longer supported. The trigger button can now be placed anywhere on the screen.

right

Added in version 6.15.0

Optimizes the layout for right-hand use of the SparkScanView.

left

Added in version 6.15.0

Optimizes the layout for left-hand use of the SparkScanView.

enum SparkScanMiniPreviewSize

Added in version 7.0.0

The size of the mini preview in SparkScanView. Used in SparkScanViewSettings.defaultMiniPreviewSize.

regular

Added in version 7.0.0

Regular, smaller size of the mini preview.

expanded

Added in version 7.0.0

Expanded, larger size of the mini preview.

enum SparkScanViewState

Added in version 7.0.0

The view state of SparkScanView.

initial

Added in version 7.0.0

The initial view state for a few moments after SparkScanView is created.

idle

Added in version 7.0.0

SparkScan is displaying only the collapsed capture button.

inactive

Added in version 7.0.0

SparkScan is displaying an expanded capture button, and if the SparkScanPreviewBehavior of the current SparkScanScanningMode is SparkScanPreviewBehavior.persistent, we are also displaying camera feed through the mini preview but no actual scanning is taking place. This state is reachable after scanning or after a SparkScanViewSettings.inactiveStateTimeout timeout.

active

Added in version 7.0.0

We are actively recognising barcodes, mini preview and expanded capture button are visible.

error

Added in version 7.0.0

User returns SparkScanBarcodeFeedback.Error from the SparkScanView.feedbackDelegate. Mini preview is visible with a frozen frame and expanded capture button is visible. If capture button is tapped or after a SparkScanBarcodeErrorFeedback.resumeCapturingDelay timeout is reached we move to active state.

jsonString
open var jsonString: String { get }

Added in version 7.0.0

Serialize the SparkScan view state in a JSON string.

SparkScanViewUIDelegate
protocol SparkScanViewUIDelegate : NSObjectProtocol

Added in version 6.16.0

barcodeFindButtonTapped
optional func barcodeFindButtonTapped(in view: SparkScanView) -> Void

Added in version 6.26.0

Callback method that can be used to define an action that should be performed when barcode find button is tapped from the toolbar. Called from the main thread.

barcodeCountButtonTapped
optional func barcodeCountButtonTapped(in view: SparkScanView) -> Void

Added in version 6.16.0

Callback method that can be used to define an action that should be performed when barcode count button is tapped from the toolbar. Called from the main thread.

labelCaptureButtonTapped
optional func labelCaptureButtonTapped(in view: SparkScanView) -> Void

Added in version 7.0.0

Callback method that can be used to define an action that should be performed when label capture button is tapped from the toolbar. Called from the main thread.

sparkScanView
optional func sparkScanView(_ view: SparkScanView, didChange scanningMode: any SparkScanScanningMode) -> Void

Added in version 6.20.0

Callback method that will be called when the currently used SparkScanScanningMode changes. Called from the main thread.

sparkScanView
optional func sparkScanView(_ view: SparkScanView, didChange viewState: SparkScanViewState) -> Void

Added in version 7.0.0

Callback method that will be called when SparkScanViewState changes. Called from the main thread.

SparkScanScanningMode
protocol SparkScanScanningMode : NSObjectProtocol

Added in version 6.16.0

The base class for setting a default scanning mode to SparkScanViewSettings. Can be either SparkScanScanningModeTarget or SparkScanScanningModeDefault.

jsonString
open var jsonString: String { get }

Added in version 6.16.0

Returns the JSON representation.

SparkScanScanningModeTarget
open class SparkScanScanningModeTarget : NSObject, SparkScanScanningMode

Added in version 6.16.0

Target scanning mode. This is meant and optimized to scan codes further away.

init
init()

Added in version 6.23.0

init
init(scanningBehavior: SparkScanScanningBehavior, previewBehavior: SparkScanPreviewBehavior)

Added in version 6.23.0

Constructs a new target scanning mode with the provided capture mode and preview behavior.

scanningBehavior
open var scanningBehavior: SparkScanScanningBehavior { get }

Added in version 6.16.0

The scanning mode provided in the constructor.

previewBehavior
open var previewBehavior: SparkScanPreviewBehavior { get }

Added in version 6.23.0

The preview behavior provided in the constructor.

jsonString
open var jsonString: String { get }

Added in version 6.16.0

Returns the JSON representation.

SparkScanScanningModeDefault
open class SparkScanScanningModeDefault : NSObject, SparkScanScanningMode

Added in version 6.16.0

This is the standard scanning mode for SparkScan.

init
init()

Added in version 6.16.0

init
init(scanningBehavior: SparkScanScanningBehavior, previewBehavior: SparkScanPreviewBehavior)

Added in version 6.23.0

Constructs a new default scanning mode with the provided capture mode and preview behavior.

scanningBehavior
open var scanningBehavior: SparkScanScanningBehavior { get }

Added in version 6.16.0

The scanning mode provided in the constructor.

previewBehavior
open var previewBehavior: SparkScanPreviewBehavior { get }

Added in version 6.23.0

The preview behavior provided in the constructor.

jsonString
open var jsonString: String { get }

Added in version 6.16.0

Returns the JSON representation.

SparkScanView
open class SparkScanView : UIView

Added in version 6.15.0

SparkScan comes with a ready-to-use UI and scanning modes that are purpose-built to tackle high-volume scanning at close range. The SparkScanView integrates with any app without requiring app redesign or customization. It includes:

  • camera preview screen

  • large-sized scan button

  • quick access toolbar to adjust scanning settings

feedbackDelegate
open weak var feedbackDelegate: SparkScanFeedbackDelegate? { get, set }

Added in version 6.23.0

Sets the feedback delegate. If no delegate is set, the default SparkScanBarcodeFeedback.Success feedback is emitted.

init
init(parentView: UIView, context: DataCaptureContext, sparkScan: SparkScan, settings: SparkScanViewSettings)

Added in version 6.15.0

Constructs a new SparkScan view and adds it to the provided parentView. When the settings are provided, those will be used to set the default behaviour and look of the view.

sparkScanView = SparkScanView(parentView: view, // For example the view controller's view property.
                              context: context,
                              sparkScan: sparkScan,
                              settings: viewSettings)
prepareScanning
open func prepareScanning() -> Void

Added in version 6.16.0

Method to call for preparing the mode for scanning. For instance, it can be called when the view controller containing SparkScanView is presented (i.e., UIViewController’s viewWillAppear).

Important

This method must be called before using the SparkScanView for scanning.

stopScanning
open func stopScanning() -> Void

Added in version 6.16.0

Method to call for stopping the mode. For instance, it can be called when the view controller containing SparkScanView is about to disappear (i.e., UIViewController’s viewWillDisappear).

Important

This method must be called to ensure that all resources used by SparkScanView are released. If your workflow involves using other Scandit modes, call this method before switching to another mode.

startScanning
open func startScanning() -> Void

Added in version 6.15.0

Starts the scanning process. You can call this method if you want to trigger the scanning process without any user interaction.

pauseScanning
open func pauseScanning() -> Void

Added in version 6.15.0

Pauses the scanning process. You can call this method if you want to trigger pausing the scanning process without any user interaction.

showToast
open func showToast(_ text: String) -> Void

Added in version 6.18.0

Shows a toast with text inside the mini preview.

scanningMode
open var scanningMode: any SparkScanScanningMode { get }

Added in version 6.20.0

Returns the currently used SparkScanScanningMode.

defaultBrush
open class var defaultBrush: Brush { get }

Added in version 6.16.0

Returns the default brush used by the overlay.

uiDelegate
open weak var uiDelegate: SparkScanViewUIDelegate? { get, set }

Added in version 6.16.0

Sets the listener which is called whenever a barcode find button or barcode count button is tapped from the toolbar.

isBarcodeCountButtonVisible
open var isBarcodeCountButtonVisible: Bool { get, set }

Added in version 6.16.0

Indicates whether the barcode count button should be shown to the user.

Default is false.

isBarcodeFindButtonVisible
open var isBarcodeFindButtonVisible: Bool { get, set }

Added in version 6.26.0

Indicates whether the barcode find button should be shown to the user.

Default is false.

isLabelCaptureButtonVisible
open var isLabelCaptureButtonVisible: Bool { get, set }

Added in version 7.0.0

Indicates whether the label capture button should be shown to the user.

Default is false.

isTargetModeButtonVisible
open var isTargetModeButtonVisible: Bool { get, set }

Added in version 6.16.0

Indicates whether the target mode button should be shown to the user.

Default is false.

isScanningBehaviorButtonVisible
open var isScanningBehaviorButtonVisible: Bool { get, set }

Added in version 6.15.0

Indicates whether the scanning behavior button should be shown to the user.

Default is false.

isTorchButtonVisible
open var isTorchButtonVisible: Bool { get, set }

Added in version 6.15.0

Indicates whether the torch button should be shown to the user.

Default is true.

Deprecated since version 7.0: The torch button has been moved to the mini preview. Use isTorchControlVisible instead.

isHandModeButtonVisible
open var isHandModeButtonVisible: Bool { get, set }

Added in version 6.15.0

Indicates whether the hand mode button should be shown to the user.

Default is false.

Deprecated since version 7.0: Hand mode is no longer supported. The trigger button can now be placed anywhere on the screen.

isZoomSwitchControlVisible
open var isZoomSwitchControlVisible: Bool { get, set }

Added in version 6.18.0

Indicates whether the zoom switch control should be shown to the user.

Default is true.

isTriggerButtonVisible
open var isTriggerButtonVisible: Bool { get, set }

Added in version 7.0.0

Indicates whether the trigger button should be shown to the user.

Default is true.

isPreviewSizeControlVisible
open var isPreviewSizeControlVisible: Bool { get, set }

Added in version 6.23.0

Indicates whether the mini preview size control should be shown to the user.

Default is true.

isTorchControlVisible
open var isTorchControlVisible: Bool { get, set }

Added in version 7.0.0

Indicates whether the torch control should be shown to the user.

Default is true.

Note

If SparkScanViewSettings.defaultTorchState is set to TorchState.auto, torch control is hidden.

isPreviewCloseControlVisible
open var isPreviewCloseControlVisible: Bool { get, set }

Added in version 7.0.0

Indicates whether the mini preview close control should be shown to the user.

Default is true.

isCameraSwitchButtonVisible
open var isCameraSwitchButtonVisible: Bool { get, set }

Added in version 6.24.0

Indicates whether the camera switch button should be shown to the user.

Default is false.

Note

This API is still in beta and may change in future versions of Scandit Data Capture SDK.

stopCapturingText
open var stopCapturingText: String? { get, set }

Added in version 6.15.0

Sets the default text to display in the button for the stop capturing action.

When scanning using hold-to-scan interaction default is “RELEASE TO STOP SCANNING” otherwise default is “STOP SCANNING”

Deprecated since version 7.0: The trigger button no longer displays text.

startCapturingText
open var startCapturingText: String? { get, set }

Added in version 6.15.0

Sets the default text to display in the button for the start capturing action.

When SparkScanViewSettings.isHoldToScanEnabled is enabled then default is “TAP OR HOLD TO SCAN” otherwise default is “TAP TO SCAN”

Deprecated since version 7.0: The trigger button no longer displays text.

resumeCapturingText
open var resumeCapturingText: String? { get, set }

Added in version 6.15.0

Sets the default text to display in the button for the resume capturing action.

Default is “RESUME SCANNING”

Deprecated since version 7.0: The trigger button no longer displays text.

scanningCapturingText
open var scanningCapturingText: String? { get, set }

Added in version 6.16.0

Sets the default text to display in the button when scanning in SparkScanScanningBehavior.single.

Default is null.

Deprecated since version 7.0: The trigger button no longer displays text.

triggerButtonCollapsedColor
open var triggerButtonCollapsedColor: UIColor? { get, set }

Added in version 7.0.0

Sets the background color of the trigger button when button is collapsed.

triggerButtonExpandedColor
open var triggerButtonExpandedColor: UIColor? { get, set }

Added in version 7.0.0

Sets the background color of the trigger button when button is expanded.

triggerButtonAnimationColor
open var triggerButtonAnimationColor: UIColor? { get, set }

Added in version 7.0.0

Sets the color of the pulsing animation around the trigger button, which is shown when the scanner is active.

triggerButtonTintColor
open var triggerButtonTintColor: UIColor? { get, set }

Added in version 7.0.0

Sets the trigger button tint color.

captureButtonBackgroundColor
open var captureButtonBackgroundColor: UIColor? { get, set }

Added in version 6.15.0

Sets the background color of the capture button.

Default is #12161999.

Deprecated since version 7.0: Use triggerButtonCollapsedColor and triggerButtonExpandedColor instead.

captureButtonActiveBackgroundColor
open var captureButtonActiveBackgroundColor: UIColor? { get, set }

Added in version 6.16.0

Sets the background color of the capture button when scanning.

Default is #12161966.

Deprecated since version 7.0: This property is not relevant anymore.

captureButtonTintColor
open var captureButtonTintColor: UIColor? { get, set }

Added in version 6.16.0

Sets the capture button icon and text color.

Default is #FFFFFF.

Deprecated since version 7.0: Use triggerButtonTintColor instead.

toolbarBackgroundColor
open var toolbarBackgroundColor: UIColor? { get, set }

Added in version 6.16.0

Sets the toolbar background color.

Default is #121619CC.

toolbarIconActiveTintColor
open var toolbarIconActiveTintColor: UIColor? { get, set }

Added in version 6.16.0

Sets the toolbar icon active color.

Default is #FBC02C.

toolbarIconInactiveTintColor
open var toolbarIconInactiveTintColor: UIColor? { get, set }

Added in version 6.16.0

Sets the toolbar icon inactive color.

Default is #FFFFFF.

triggerButtonImage
open var triggerButtonImage: UIImage? { get, set }

Added in version 7.0.0

The image displayed in the trigger button.

Note

Troubleshooting: Buttons Not Working With Navigation Header

When using the SparkScanView component with React Navigation and headerShown: true, you may encounter an issue where the Buttons within your SparkScanView don’t respond to touch events. This is a known issue with React Navigation’s header implementation.

The Issue

The navigation header can interfere with touch event handling for components rendered within certain custom views like SparkScanView. While the buttons appear to be functioning visually, their onPress events do not trigger when the screen includes a header.

Solution

Try this workaround if you encounter this issue:

Use TouchableOpacity instead of Button

<TouchableOpacity
  onPressIn={() => handleButtonPress()}>
  <Text>Scan</Text>
</TouchableOpacity>

or

<TouchableOpacity
  onPressOut={() => handleButtonPress()}>
  <Text>Scan</Text>
</TouchableOpacity>

Ensure you’re importing TouchableOpacity from ‘react-native’

Some users have found that using the TouchableOpacity component from ‘react-native-gesture-handler’ causes issues, while the one from ‘react-native’ works correctly.