NFC scanner

Use this integration to scan NFC tags.

Introduction

This integration can be used to scan NFC tags near the phone.

Integration name: NfcIntegration

Description of the NFC integration

NFC isn’t available on all kinds of devices. Especially the cheap Android phones does’t have af NFC reader. So always call isNfcSupported() to make sure the phone has a compatible NFC tag reader. The app doesn’t have access to ask the user for permission to scan NFC tags. Instead a call to isNfcEnabled() is necessary to determine wether the app has permission to read NFC tags. 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(): bool

Returns a boolean indicating wether scanning of NFC tags is supported by the device.

isNfcEnabled

isNfcEnabled(): bool

Returns a boolean indicating wether scanning of NFC tags is enabled on the device. If it isn’t enabled no API exists to ask the user. The user has to go to the settings on the device and enable the NFC functionality.

initialize

initialize(): { result: bool, error: string }

Initializes the NFC service and starts scanning after NFC tags.

Returns an object containing a result set to true if the scanning completed successfully. If it didn’t complete successfully result will be set to false and error will contain the corresponding error message.

stopListening

stopListening(): bool

Stops the NFC scanner. Returns true on success and false if it fails.

Events

nfcTagResultReceivedEvent

nfcTagResultReceivedEvent(message): { result: bool, error: string, nfcTagInfo: string }

When a NFC tag is scanned, this event will be raised. In cases where the NFC tag contains no content or isn’t supported result will be false and error will contain the corresponding error message. If the NFC tag is read successfully result will be true and nfcTagInfo will contain the content read from the NFC tag.