NFC API
Installation
npm install @cutos/core
npm install @cutos/devices
Import dependencies
import {CoreAPI} from '@cutos/core';
import {DeviceNFC} from '@cutos/devices';
DeviceNFC
Constructor, create NFC device instance
let devNFC = new DeviceNFC(name);
- name: NFC device name
Example:
devNFC = new DeviceNFC('demo-nfc');
DeviceNFC.init
NFC device initialization
devNFC.init(callback);
- callback: callback function
Example:
devNFC.init((result, error) => {
if (!error) {
console.log('onDeviceCreate', result)
} else {
console.log(error)
}
});
DeviceNFC.connect
Connect NFC
devNFC.connect(callback);
- callback: callback function
Example:
devNFC.connect((result) => {
if (result.status) {
console.log('connect success:', result)
} else {
console.log('connect failed:', result.msg)
}
});
DeviceNFC.onData
Receive NFC information
DeviceNFC.onData(callback)
- callback: callback function
Example:
DeviceNFC.onData((data) => {
console.log('data', data)
})
- Return result example:
{
"id": "110111201"
}