npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

capacitor-nfc-plugin

v1.1.4

Published

Capacitor NFC plugin for device-to-device communication and WebRTC initialization

Downloads

376

Readme

Capacitor NFC Plugin

npm version npm downloads npm license

Install

npm install capacitor-nfc-plugin
npx cap sync

Usage Examples

Basic NFC Reading

// Read any NFC tag
const readResult = await Nfc.read();
console.log('Read Result:', readResult);

// Get detailed tag info
const tagInfo = await Nfc.getTagInfo();
console.log('Tag Info:', tagInfo);

Reading Different Card Types

  1. NDEF Formatted Cards:
// Read NDEF data
const result = await Nfc.read();
// Result will contain formatted NDEF messages
console.log('NDEF Data:', result.records);
  1. MIFARE Classic Cards:
// Read MIFARE Classic card
const tagInfo = await Nfc.getTagInfo();
if (tagInfo.type === 'MIFARE_CLASSIC') {
    console.log('Card Size:', tagInfo.size);
    console.log('Sector Count:', tagInfo.sectorCount);
    console.log('Block Count:', tagInfo.blockCount);
    // If authentication succeeded, you'll see block0 data
    if (tagInfo.block0) {
        console.log('Block 0 Data:', tagInfo.block0);
    }
}
  1. ISO-DEP Cards (Banking cards, ID cards):
// Read ISO-DEP card with specific AID
await Nfc.write({
    mode: 'reader',
    cardType: 'iso_dep',
    aid: 'F0010203040506', // Replace with your card's AID
    text: ''  // Empty text indicates read mode
});

// Listen for the read result
Nfc.addListener('readSuccess', (event) => {
    console.log('Card Data:', event.data);
    console.log('Historical Bytes:', event.historicalBytes);
});

Example Response Data

  1. MIFARE Classic Response:
{
    "type": "MIFARE_CLASSIC",
    "size": 1024,
    "sectorCount": 16,
    "blockCount": 64,
    "block0": "0123456789ABCDEF",
    "maxTransceiveLength": 253
}
  1. ISO-DEP Response:
{
    "type": "ISO_DEP",
    "hiLayerResponse": "0123456789",
    "historicalBytes": "ABCDEF0123",
    "cardData": "0123456789ABCDEF"
}
  1. NDEF Message Response:
{
    "type": "NDEF",
    "records": [
        {
            "type": "text/plain",
            "payload": "Hello NFC",
            "identifier": ""
        }
    ]
}

API

echo(...)

echo(options: { value: string; }) => Promise<{ value: string; }>

| Param | Type | | ------------- | ------------------------------- | | options | { value: string; } |

Returns: Promise<{ value: string; }>


API Reference

Methods

isEnabled()

Check if NFC is available and enabled.

  • Returns: Promise<{ enabled: boolean }>

startScanning()

Start listening for NFC tags.

  • Returns: Promise<void>

stopScanning()

Stop listening for NFC tags.

  • Returns: Promise<void>

write(options: WriteOptions)

Write data to an NFC tag or share data via HCE.

  • Parameters:
    interface WriteOptions {
      text?: string;
      webrtcData?: WebRTCConnectionInfo;
      mode?: 'reader' | 'emulator' | 'read';
      cardType?: string;
      aid?: string;
      secure?: boolean;
      timeout?: number;
    }
  • Returns: Promise<void>

getTagInfo()

Get technical details about a detected NFC tag.

  • Returns: Promise<NFCTagInfo>

Events

nfcTagDetected

Emitted when an NFC tag is detected.

  • Data: { messages: NFCTagData[] }

nfcStatus

Emitted when NFC status changes.

  • Data: { status: string }

writeSuccess

Emitted when data is successfully written.

  • Data: { written: boolean, type: string, message: string }

writeError

Emitted when a write operation fails.

  • Data: { error: string }

readSuccess

Emitted when data is successfully read.

  • Data: { type: string, data: string }

webrtcOffer

Emitted when a WebRTC offer is received.

  • Data: WebRTCConnectionEvent

webrtcAnswer

Emitted when a WebRTC answer is received.

  • Data: WebRTCConnectionEvent

Supported Tag Types

Android

  • NDEF formatted tags
  • ISO-DEP (ISO 14443-4)
  • MIFARE Classic*
  • MIFARE Ultralight
  • ISO 15693
  • ISO 7816

iOS

  • NDEF formatted tags
  • ISO 7816 (ISO-DEP)
  • ISO 15693
  • FeliCa
  • MIFARE
  • ISO 14443 Type A/B
  • VAS (Value Added Service)

*Note:

  • MIFARE Classic support varies by device manufacturer on Android
  • iOS 13+ required for tag reading
  • iOS 14+ required for Value Added Service (VAS) tags
  • Some tag types may require special entitlements in iOS

iOS Configuration

  1. Add NFC capabilities in Xcode:

    • Navigate to your target's "Signing & Capabilities"
    • Click "+" and add "Near Field Communication Tag Reading"
  2. Add required entries to Info.plist:

<!-- Basic NFC reading -->
<key>NFCReaderUsageDescription</key>
<string>This app needs access to NFC reading to communicate with NFC tags and devices.</string>

<!-- For ISO7816, ISO15693, MIFARE tags -->
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
    <string>NDEF</string>
    <string>TAG</string>
</array>

<!-- For specific Application IDs (AIDs) -->
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
    <string>F0010203040506</string>
</array>

<!-- For VAS (iOS 14+) -->
<key>com.apple.developer.nfc.readersession.vpay</key>
<true/>
  1. Required Entitlements:
  • com.apple.developer.nfc.readersession
  • com.apple.developer.nfc.readersession.formats
  • com.apple.developer.nfc.readersession.iso7816.select-identifiers (for ISO7816)
  • com.apple.developer.nfc.readersession.vpay (for VAS)
  1. Minimum iOS Version Requirements:
  • iOS 13+: Basic NFC tag reading
  • iOS 14+: VAS support
  • iOS 15+: Enhanced security features

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

Support

For issues and feature requests, please use the GitHub issue tracker.

Credits

Created by Mark Cleverdon (@mpcleverdon)

iOS Support Matrix

| Feature | Support Level | Minimum iOS | Notes | |-----------------------|---------------|-------------|--------------------------------------| | NDEF Reading | Full | iOS 13.0 | All NDEF types supported | | NDEF Writing | Full | iOS 13.0 | All NDEF types supported | | MIFARE Reading | Partial | iOS 13.0 | DESFire & Ultralight only | | ISO-DEP/ISO7816 | Full | iOS 13.0 | Requires entitlements | | FeliCa | Full | iOS 13.0 | Requires entitlements | | ISO15693 | Full | iOS 13.0 | Including tag emulation | | Card Emulation | Partial | iOS 13.0 | ISO15693 & FeliCa only | | Tag Cloning | Partial | iOS 13.0 | Limited to supported protocols |

Note: Some features require special entitlements from Apple:

  • FeliCa card emulation
  • Custom AIDs for ISO7816
  • VAS (Value Added Service) support