@kduma-autoid/capacitor-sunmi-scanhead
Sunmi Scan Head bindings for Capacitor
Install
npm install @kduma-autoid/capacitor-sunmi-scanhead
npx cap sync
Configuration
You can disable auto binding of the service by setting bindOnLoad to false in the plugin configuration in capacitor.config.ts.
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: "com.company.app",
...
plugins: {
SunmiScanHead: {
bindOnLoad: true
}
}
}
export default config;
API
bindService()
bindService() => Promise<void>
bind scan service
unBindService()
unBindService() => Promise<void>
unbind scan service
scan()
scan() => Promise<void>
Start scanner
stop()
stop() => Promise<void>
Stop scanner
getScannerModel()
getScannerModel() => Promise<{ model: number; }>
Get scanner model ID
Returns: Promise<{ model: number; }>
clearConfig()
clearConfig() => Promise<void>
Clear scanner configuration (reset to default)
setTrigger(...)
setTrigger(options: { enabled: boolean; }) => Promise<void>
Enable or disable trigger button
options | { enabled: boolean; } |
setOutputMode(...)
setOutputMode(options: { mode: OutputMode.DISABLED; } | { mode: OutputMode.KEYSTROKE; interval?: number; tab?: boolean; enter?: boolean; } | { mode: OutputMode.DIRECTFILL; overwrite?: boolean; tab?: boolean; enter?: boolean; asEvent?: boolean; }) => Promise<void>
Set output mode
setScanMode(...)
setScanMode(options: { mode: ScanMode.TRIGGER | ScanMode.PULSE; timeout?: number; } | { mode: ScanMode.CONTINUOUS | ScanMode.LONGPRESS; sleep?: number; timeout?: number; }) => Promise<void>
Set scan mode
setReturnCodeType(...)
setReturnCodeType(options: { enabled: boolean; }) => Promise<void>
Enable or disable returning of code type with scan result
options | { enabled: boolean; } |
setBroadcast(...)
setBroadcast(options: { enabled: boolean; }) => Promise<void>
Enable or disable scan result broadcast
options | { enabled: boolean; } |
setBroadcastConfiguration(...)
setBroadcastConfiguration(options?: { scanned_intent?: string | null | undefined; start_intent?: string | null | undefined; end_intent?: string | null | undefined; intent_data_key?: string | null | undefined; intent_byte_key?: string | null | undefined; } | undefined) => Promise<void>
Set broadcast configuration
options | { scanned_intent?: string | null; start_intent?: string | null; end_intent?: string | null; intent_data_key?: string | null; intent_byte_key?: string | null; } |
addListener('onScanResult', ...)
addListener(eventName: 'onScanResult', listenerFunc: (scan: { data: string; source_bytes: string; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Listens for barcode scanner result events.
eventName | 'onScanResult' |
listenerFunc | (scan: { data: string; source_bytes: string; }) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener('onScanStart', ...)
addListener(eventName: 'onScanStart', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Listens for barcode scanner start events.
eventName | 'onScanStart' |
listenerFunc | () => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener('onScanStop', ...)
addListener(eventName: 'onScanStop', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Listens for barcode scanner stop events.
eventName | 'onScanStop' |
listenerFunc | () => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
removeAllListeners()
removeAllListeners() => Promise<void>
Removes all listeners
Interfaces
PluginListenerHandle
remove | () => Promise<void> |
Enums
OutputMode
KEYSTROKE | "keystroke" |
DIRECTFILL | "directFill" |
DISABLED | "disabled" |
ScanMode
TRIGGER | "trigger" |
CONTINUOUS | "continuous" |
PULSE | "pulse" |
LONGPRESS | "longPress" |