Develop Secure Code
NFCService Constants
NFCService Data Types
getNFCService()
isAvailable()
read()
write()
erase()
createTextRecord()
createUriRecord()
isAvailable()Use this function to determine whether NFCService functionality is available.
1import { getNFCService } from 'lightning/mobileCapabilities';
2isAvailable(): BooleanNone.
Returns true when used on a supported device, and false otherwise.
Use this function to disable or hide NFC operations on platforms where interacting with NFCs isn’t supported. For example:
1handleGetNFCClick(event) {
2 const myNFCService = getNFCService();
3 if(myNFCService.isAvailable()) {
4 // Perform NFC operations
5 }
6 else {
7 // NFCService not available, or consuming app hasn’t implemented it
8 // Not running on a device with NFC functionality, etc.
9 // Handle with message, error, beep, and so on
10 }
11}