NFC scanner
Use this integration to scan NFC tags.
Introduction
This integration can be used to scan NFC tags near the phone.
Where to find: startiapp.NfcScanner
Description of the NFC integration
NFC isn’t available on all kinds of devices. Especially the cheap Android phones doesn’t have a NFC scanner. So always call isNfcSupported()
to make sure the phone has a compatible NFC tag reader. Reading NFC tags has it limitations. Here are the list of supported NFC tags: NDEF, MIFARE (only Android), ISO/IEC 14443, ISO/IEC 15693, ISO/IEC 7816 (only Android) & FeliCa.
Methods
isNfcSupported
isNfcSupported(): Promise<bool>
Returns a boolean indicating wether scanning of NFC tags is supported by the device.
startNfcScanner
startNfcScanner(): Promise<{success: boolean, error?: string}>
Starts the NFC scanner. This method will return a promise that will resolve to a boolean indicating wether the NFC reader was started successfully. If the NFC reader couldn’t be started result
will be false
and error
will contain the corresponding error message.
stopNfcScanner
stopNfcScanner(): Promise<{success: boolean, error?: string}>
Stops the NFC scanner. This method will return a promise that will resolve to a boolean indicating wether the NFC reader was stopped successfully.
Events
nfcTagScanned
startiapp.NfcScanner.addEventListener(
'nfcTagScanned',
function (event) {
console.log(event.detail);
}
);
This event is fired when a NFC tag is scanned. The event detail will contain the following data:
{
success: boolean;
error?: string;
result?: Array<{
mimeType: string | null;
message: string;
typeFormat: "Empty" | "WellKnown" | "Mime" | "Uri" | "External" | "Unknown" | "Unchanged" | "Reserved";
}>
}