Nfc Reader
npm install sdk-reader-nfcbash
npm install sdk-reader-nfc
npx cap sync
`
API
startScan()
* enableAutoScan()
* stopScan()
* addListener(string, ...)
* parseMRZFromQR(...)
* startReadCCCD(...)
* stopReadCCCD()
* initializeBarcodeReader()
* setBarcodeScanMode(...)
* startBarcodeScan()
* stopBarcodeScan()
* sendBarcodeCommand(...)
* releaseBarcodeReader()
* Interfaces
$3
`typescript
startScan() => Promise
`Bắt đầu quét thẻ NFC (một lần)
Returns: Promise<CardInfo>
--------------------
$3
`typescript
enableAutoScan() => Promise
`Bật chế độ quét liên tục
--------------------
$3
`typescript
stopScan() => Promise
`Dừng quét thẻ NFC
--------------------
$3
`typescript
addListener(eventName: string, listenerFunc: (data: CardInfo) => void) => Promise<{ remove(): Promise; }>
`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>; }>
--------------------
$3
`typescript
parseMRZFromQR(options: { qrData: string; }) => Promise
`Tính MRZ từ dữ liệu QR CCCD
| Param | Type | Description |
| ------------- | -------------------------------- | ------------ |
|
options | { qrData: string; } | - Dữ liệu QR |Returns: Promise<ParseMRZResult>
--------------------
$3
`typescript
startReadCCCD(options: StartReadCCCDOptions) => Promise
`Bắt đầu đọc chip CCCD
| Param | Type | Description |
| ------------- | --------------------------------------------------------------------- | ----------- |
|
options | StartReadCCCDOptions | - MRZ từ QR |Returns: Promise<CCCDReadResult>
--------------------
$3
`typescript
stopReadCCCD() => Promise
`Dừng đọc CCCD
--------------------
$3
`typescript
initializeBarcodeReader() => Promise
`Khởi tạo máy quét barcode
--------------------
$3
`typescript
setBarcodeScanMode(options: { mode: number; }) => Promise
`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) |--------------------
$3
`typescript
startBarcodeScan() => Promise
`Bắt đầu quét barcode
--------------------
$3
`typescript
stopBarcodeScan() => Promise
`Dừng quét barcode
--------------------
$3
`typescript
sendBarcodeCommand(options: { command: string; }) => Promise
`Gửi lệnh HEX đến máy quét barcode
| Param | Type | Description |
| ------------- | --------------------------------- | ----------- |
|
options | { command: string; } | - Lệnh HEX |--------------------
$3
`typescript
releaseBarcodeReader() => Promise
`Giải phóng máy quét barcode
--------------------
$3
#### 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 |