sdk-reader-nfc
v0.2.6
Published
Nfc Reader
Readme
sdk-reader-nfc
Nfc Reader
Install
npm install sdk-reader-nfc
npx cap syncAPI
startScan()enableAutoScan()stopScan()addListener(string, ...)parseMRZFromQR(...)startReadCCCD(...)stopReadCCCD()initializeBarcodeReader()setBarcodeScanMode(...)startBarcodeScan()stopBarcodeScan()sendBarcodeCommand(...)releaseBarcodeReader()- Interfaces
startScan()
startScan() => Promise<CardInfo>Bắt đầu quét thẻ NFC (một lần)
Returns: Promise<CardInfo>
enableAutoScan()
enableAutoScan() => Promise<void>Bật chế độ quét liên tục
stopScan()
stopScan() => Promise<void>Dừng quét thẻ NFC
addListener(string, ...)
addListener(eventName: string, listenerFunc: (data: CardInfo) => void) => Promise<{ remove(): Promise<void>; }>Thêm listener cho sự kiện NFC
| Param | Type | Description |
| ------------------ | ---------------------------------------------------------------- | ---------------------------------------- |
| eventName | string | - Tên sự kiện ('nfcScanned', 'nfcError') |
| listenerFunc | (data: CardInfo) => void | - Hàm callback xử lý sự kiện |
Returns: Promise<{ remove(): Promise<void>; }>
parseMRZFromQR(...)
parseMRZFromQR(options: { qrData: string; }) => Promise<ParseMRZResult>Tính MRZ từ dữ liệu QR CCCD
| Param | Type | Description |
| ------------- | -------------------------------- | ------------ |
| options | { qrData: string; } | - Dữ liệu QR |
Returns: Promise<ParseMRZResult>
startReadCCCD(...)
startReadCCCD(options: StartReadCCCDOptions) => Promise<CCCDReadResult>Bắt đầu đọc chip CCCD
| Param | Type | Description |
| ------------- | --------------------------------------------------------------------- | ----------- |
| options | StartReadCCCDOptions | - MRZ từ QR |
Returns: Promise<CCCDReadResult>
stopReadCCCD()
stopReadCCCD() => Promise<void>Dừng đọc CCCD
initializeBarcodeReader()
initializeBarcodeReader() => Promise<void>Khởi tạo máy quét barcode
setBarcodeScanMode(...)
setBarcodeScanMode(options: { mode: number; }) => Promise<void>Thiết lập chế độ quét barcode
| Param | Type | Description |
| ------------- | ------------------------------ | ---------------------------------------------------------- |
| options | { mode: number; } | - Chế độ quét (0: Trigger, 1: Continue, 2: Auto, 5: Sense) |
startBarcodeScan()
startBarcodeScan() => Promise<void>Bắt đầu quét barcode
stopBarcodeScan()
stopBarcodeScan() => Promise<void>Dừng quét barcode
sendBarcodeCommand(...)
sendBarcodeCommand(options: { command: string; }) => Promise<void>Gửi lệnh HEX đến máy quét barcode
| Param | Type | Description |
| ------------- | --------------------------------- | ----------- |
| options | { command: string; } | - Lệnh HEX |
releaseBarcodeReader()
releaseBarcodeReader() => Promise<void>Giải phóng máy quét barcode
Interfaces
CardInfo
| Prop | Type |
| -------------------- | ------------------- |
| 'Card Number' | string |
| 'Holder Name' | string |
| 'Expiry Date' | string |
| Type | string |
| 'Track 2 Data' | string |
| Error | string |
ParseMRZResult
| Prop | Type |
| ------------- | ------------------- |
| mrz | string |
| address | string |
| name | string |
CCCDReadResult
| Prop | Type |
| ------------ | ------------------- |
| status | string |
| info | any |
| image | string |
StartReadCCCDOptions
| Prop | Type |
| --------- | ------------------- |
| mrz | string |
