> ## Documentation Index
> Fetch the complete documentation index at: https://docs.taprails.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# NFC Utilities

> Low-level NFC control functions for checking support, enabling the reader, and cancelling sessions.

These utilities give you fine-grained control over the NFC subsystem. They are used internally by `writeSignedInvoice` and `readSignedInvoice` and are exported for advanced use cases.

## checkNFCSupport

```ts theme={null}
async function checkNFCSupport(): Promise<boolean>
```

Returns `true` if the device has NFC hardware; `false` otherwise. Does not check if NFC is enabled.

```ts theme={null}
const supported = await checkNFCSupport();
if (!supported) {
  Alert.alert('NFC not available on this device');
}
```

***

## checkNFCEnabled

```ts theme={null}
async function checkNFCEnabled(): Promise<boolean>
```

Returns `true` if NFC is currently enabled in device settings. Only Android returns meaningful values — on iOS, NFC is always on when supported.

```ts theme={null}
const enabled = await checkNFCEnabled();
if (!enabled) {
  Alert.alert('Please enable NFC in Settings');
}
```

***

## enableNFCReader

```ts theme={null}
async function enableNFCReader(): Promise<void>
```

Checks support and enabled state, then calls `NfcManager.start()`. Throws `NFCPaymentError` if:

* `NFCErrorCode.NOT_SUPPORTED` — no NFC hardware
* `NFCErrorCode.NOT_ENABLED` — NFC is off

Used internally by `readSignedInvoice`. You typically do not need to call this directly.

***

## cancelNFCOperation

```ts theme={null}
async function cancelNFCOperation(): Promise<void>
```

Cancels any in-progress NFC operation by:

1. Unregistering tag event listeners
2. Cancelling any active technology session
3. Stopping and clearing the active HCE session (if running)

Call this when:

* The user navigates away while NFC is active
* You need to restart an NFC session
* Your component unmounts during an active NFC scan

```tsx theme={null}
useEffect(() => {
  return () => {
    // Always clean up NFC on unmount
    cancelNFCOperation().catch(() => {});
  };
}, []);
```

<Note>
  `readSignedInvoice` and `writeSignedInvoice` automatically call `cancelNFCOperation` before starting a new session, so you don't need to call it manually between sequential operations on the same screen.
</Note>
