read(options)
Reads an NFC tag and returns the data read from it.
options
—(Required) AnNFCServiceOptions
object to configure the NFCService request.
A Promise object that resolves to an array containing a single NFCMessage object.
A rejected promise returns a NFCServiceFailure
.
Use this function to read data from an NFC tag.
- The design pattern of returning an array containing a single
NFCMessage
object instead of just theNFCMessage
object is intentional. It’s to make extensibility updates easier, in case future enhancements to NFCService include the ability to read multiple NFC tags. - If an error occurs, the error is returned via a rejected promise. Handle errors in a
catch
clause. - When the user cancels the operation, the promise is rejected with a
NFCServiceFailure.code
value of USER_DISMISSED.
See Also