Erase the contents of an NFC tag.

Using erase() is an inherently dangerous action, as it allows data to be irreversibly deleted. Use caution when using this functionality in your component. At an absolute minimum, consider adding a confirmation window for your users that clearly states the outcome of the action, with an option for them to cancel if they wish.

The erase() function can only be performed on writable NFC tags. Attempting this function on a read-only NFC tag will result in an error.

  • options—(Required) 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 erase data from 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.

See Also