Develop Secure Code
NFCService Constants
NFCService Data Types
getNFCService()
isAvailable()
read()
write()
erase()
createTextRecord()
createUriRecord()
createTextRecord(payload)Given a text payload, this function creates a properly formatted NFCRecord to be written to an NFC tag.
1import { getNFCService } from 'lightning/mobileCapabilities';
2createTextRecord(payload: TextPayload): Promise<Object>;A Promise object that resolves to an NFCRecord object.
A rejected promise returns an NFCServiceFailure.
Use this function to create and return an NFC record to use as a parameter for the write() function.
1myNFCService
2 .createTextRecord(payload)
3 .then((result) => {
4 this.newNFCRecord = result;
5 })
6 .catch((error) => {
7 console.error("Error code: " + error.code);
8 console.error("Error message: " + error.message);
9 });catch clause.NFCServiceFailure.code value of USER_DISMISSED.See Also