NFCService Data Types

NFCService defines and uses several data types.

An object returned by an NFC read() operation.

Property NameTypeDescriptionExample
totalByteLengthNumberThe size, in number of bytes, of the data received by the read() operation.256
recordsNFCMessageRecord[]An array containing a single NFCMessageRecord object, which in turn contains the payload from the NFC tag.[NFCMessageRecord]

An object within an NFCMessage object, containing the payload read from an NFC tag.

Property NameTypeDescriptionExample
parsedNFCRecordContains the parsed values of the raw data read from the NFC tag. The parsing operation only occurs if the value of the typeNameFormat property on the NFCRecord object is "WELLKNOWN". Otherwise, this property’s value is null.
rawNFCRecordContains the raw base64 data string read from the NFC tag.

An object containing one record of data from an NFC tag scan.

Property NameTypeDescriptionExample
typeNameFormatTypeNameFormatThe Type Name Format field of the payload, as defined by the NDEF specification."WELLKNOWN" See TypeNameFormat for a list of possible values.
typeStringThe type of the payload, as defined by the NDEF specification."T" (when payload is of type text); "U" (when payload is of type URI)
identifierStringThe identifier of the payload, as defined by the NDEF specification, or an empty string if no identifier data was present in the tag.
payloadStringThe content of the record, encoded in base64 format."V2XigJlyZSBTYWxlc2ZvcmNlLCBG9tZXIgY29tcGFueS4"

An object containing raw text input, to be converted into an NFCRecord.

Property NameTypeDescriptionExample
textStringThe raw text payload to be converted."We’re Salesforce, the customer company."
langIdStringThe ISO 639-1 language ID of the text."en"

An object containing configuration details for an NFC interaction.

Property NameTypeDescriptionExample
instructionTextStringOptional. Provides instructions to display in the user interface. Defaults to no text."Hold your phone near the tag to read."
successTextStringOptional. Provides a message to display in the user interface when an NFC operation is successfully completed. Defaults to no text."Tag read successfully!"

An object representing an error that occurred when accessing NFCService features.

Property NameTypeDescription
codeNFCServiceFailureCodeA value representing the reason for an error. See NFCServiceFailureCode for the list of possible values.
messageStringA string value describing the reason for the failure. This value is suitable for use in user interface messages. The message is provided in English and isn’t localized.

See Also