NFC Technology Overview

Near Field Communication enables wireless data exchange over short distances (typically 4cm or less). NFC operates at 13.56 MHz and supports three modes: Reader/Writer mode for interacting with NFC tags, Peer-to-Peer mode for device-to-device communication, and Card Emulation mode for mobile payments. Common use cases include contactless payments, access control, product authentication, and smart posters.

iOS Core NFC Framework

Core NFC framework (iOS 11+) enables NFC tag reading. Add Near Field Communication Tag Reading capability in Xcode, import CoreNFC framework, implement NFCNDEFReaderSessionDelegate, request NFC usage description in Info.plist, and begin reading session when user initiates action. iOS 13+ supports writing to NFC tags and reading passport data.

iOS requires user-initiated NFC sessions - you cannot scan in background, ensuring privacy and preventing unwanted tag reads.

Android NFC APIs

Android has supported NFC since API 9. Declare NFC permission and feature in AndroidManifest.xml, use NfcAdapter to check NFC availability, implement foreground dispatch system for priority handling, parse NDEF messages from intents, and handle different tag technologies (NfcA, NfcB, NfcF, NfcV, IsoDep, MifareClassic, MifareUltralight).

Reading NFC Tags

NDEF (NFC Data Exchange Format) is the standard format for NFC data. Parse NDEF messages containing records with type, ID, and payload. Common record types include URI (web links), Text (plain text), Smart Poster (URL with metadata), and MIME (custom data). Handle malformed tags gracefully and validate data before processing to prevent security issues.

Writing to NFC Tags

Write NDEF messages to compatible tags. Check if tag is writable and has sufficient capacity, create NDEF message with appropriate records, write message to tag, and optionally make tag read-only for security. Use write protection for tags containing sensitive data or permanent information like product authentication codes.

Payment Integration

Implement contactless payments using Apple Pay (Wallet framework) or Google Pay (Google Pay API). These use NFC card emulation mode but don't require direct NFC API access. Configure merchant ID, create payment request with items and shipping, present payment sheet, and process payment token on your server. NFC payment data is encrypted and tokenized for security.

Security Considerations

NFC security challenges include eavesdropping (reading data from nearby transactions), data corruption, relay attacks, and malicious tags. Mitigate risks by encrypting sensitive data, validating tag authenticity, implementing secure channels for critical operations, educating users about NFC security, and using secure element for payment credentials.