Skip to content

NFC-Ndef

.connect

TIP

The API usage is as follows: Ndef.connect()

  • Functional description: Connect NFC tag
  • Parameters and descriptions: Object object。
    PropertiesTypeDefault valueRequiredDescription
    successFunction-NoCallback function for successful interface call
    failFunction-NoCallback function for failed interface call
    completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)

.close

TIP

The API usage is as follows: Ndef.close()

  • Functional description: Disconnect

  • Parameters and descriptions: Object object。

    PropertiesTypeDefault valueRequiredDescription
    successFunction-NoCallback function for successful interface call
    failFunction-NoCallback function for failed interface call
    completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • Error code

    Error codeError messageDescription
    13000The device does not support NFC-
    13001The system NFC switch is not turned on-
    13010Unknown error-
    13019user is not authorizedThe user is not authorized
    13011invalid parameterInvalid parameters
    13012parse NdefMessage failedFailed to parse parameters into NdefMessage
    13021NFC discovery already startedNFC scanning has started
    13018NFC discovery has not startedAttempt to stop NFC scanning when NFC scanning has not started
    13022Tech already connectedThe tag is already connected
    13023Tech has not connectedAttempt to disconnect when the tag is not connected
    13013NFC tag has not been discoveredNFC tag not scanned
    13014invalid techInvalid tag technology
    13015unavailable techFailed to obtain the corresponding technology from the tag
    13024function not supportThe current tag technology does not support this function
    13017system internal errorRelated read and write operations failed
    13016connect failConnection failed

.setTimeout

TIP

The API usage is as follows: Ndef.setTimeout(Object object)

  • Functional description: Set timeout

  • Parameters and descriptions: Object object。

    PropertiesTypeDefault valueRequiredDescription
    timeoutnumber-YesSet timeout (ms)
    successFunction-NoCallback function for successful interface call
    failFunction-NoCallback function for failed interface call
    completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • Error code

    Error codeError messageDescription
    13000The device does not support NFC-
    13001The system NFC switch is not turned on-
    13010Unknown error-
    13019user is not authorizedThe user is not authorized
    13011invalid parameterInvalid parameters
    13012parse NdefMessage failedFailed to parse parameters into NdefMessage
    13021NFC discovery already startedNFC scanning has started
    13018NFC discovery has not startedAttempt to stop NFC scanning when NFC scanning has not started
    13022Tech already connectedThe tag is already connected
    13023Tech has not connectedAttempt to disconnect when the tag is not connected
    13013NFC tag has not been discoveredNFC tag not scanned
    13014invalid techInvalid tag technology
    13015unavailable techFailed to obtain the corresponding technology from the tag
    13024function not supportThe current tag technology does not support this function
    13017system internal errorRelated read and write operations failed
    13016connect failConnection failed

.offNdefMessage

TIP

The API usage is as follows: Ndef.onNdefMessage(function callback)

  • Functional description: Cancel listening to Ndef messages
  • Parameters and descriptions: function callback。

.onNdefMessage

TIP

The API usage is as follows: Ndef.offNdefMessage(function callback)

  • Functional description: Listen to Ndef messages
  • Parameters and descriptions: function callback。

.writeNdefMessage

TIP

The API usage is as follows: Ndef.writeNdefMessage(Object object)

  • Functional description: Rewrite Ndef tag content

  • Parameters and descriptions: Object object。

    PropertiesTypeDefault valueRequiredDescription
    urisArray-Nouri array
    textsArray-Notext array
    recordsArray-NoBinary object array, need to specify id, type and payload (all ArrayBuffer type)
    successFunction-NoCallback function for successful interface call
    failFunction-NoCallback function for failed interface call
    completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • Error code

    Error codeError messageDescription
    13000The device does not support NFC-
    13001The system NFC switch is not turned on-
    13010Unknown error-
    13019user is not authorizedThe user is not authorized
    13011invalid parameterInvalid parameters
    13012parse NdefMessage failedFailed to parse parameters into NdefMessage
    13021NFC discovery already startedNFC scanning has started
    13018NFC discovery has not startedAttempt to stop NFC scanning when NFC scanning has not started
    13022Tech already connectedThe tag is already connected
    13023Tech has not connectedAttempt to disconnect when the tag is not connected
    13013NFC tag has not been discoveredNFC tag not scanned
    13014invalid techInvalid tag technology
    13015unavailable techFailed to obtain the corresponding technology from the tag
    13024function not supportThe current tag technology does not support this function
    13017system internal errorRelated read and write operations failed
    13016connect failConnection failed