Write text to an NFC tag.

  • payloads–(Required) An array of NFCRecord objects containing the raw bytes to be written.
  • options—(Optional) An NFCServiceOptions object to configure the NFCService request.

If successful, the OS returns a Promise object that resolves to null. If unsuccessful, the OS returns a Promise object that rejects to NFCServiceFailure.

Use this function to write text to an NFC tag.

  • 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.

The caller is responsible for ensuring that the payload of the NFCRecord object is correctly formatted, per NFC specifications. To help with this, we’ve provided two helper functions, createTextRecord() and createUriRecord(). By using these functions, you can convert your text or URI payload to an NFC record first, and then pass those records to the write() method to be written to the tag.

See Also