Skip to main content
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

async function checkNFCSupport(): Promise<boolean>
Returns true if the device has NFC hardware; false otherwise. Does not check if NFC is enabled.
const supported = await checkNFCSupport();
if (!supported) {
  Alert.alert('NFC not available on this device');
}

checkNFCEnabled

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.
const enabled = await checkNFCEnabled();
if (!enabled) {
  Alert.alert('Please enable NFC in Settings');
}

enableNFCReader

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

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
useEffect(() => {
  return () => {
    // Always clean up NFC on unmount
    cancelNFCOperation().catch(() => {});
  };
}, []);
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.