isAvailable()

Use this function to determine whether NFCService functionality is available.

Syntax 

1import { getNFCService } from 'lightning/mobileCapabilities';
2isAvailable(): Boolean

Parameters 

None.

Returns 

Returns true when used on a supported device, and false otherwise.

Usage 

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}