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

react-native-rfid-nfc-scanner

v1.2.0

Published

A simplified, expanded and unified NFC scanner plugin for react native.

Readme

Reading NFC tags for React Native (Android and iOS)

This project has the goal of making it easy (or easier) to scan NFC tags and read the NDEF records they contain. This is forked from the project react-native-rfid-nfc by SMARTRACTECHNOLOGY.

To read the NDEF data it makes use of the library ndef-tools-for-android.

Requirements

This library is compatible and was tested with React Native projects with version >= 0.40.0

Installation

Install the plugin via NPM:

$ npm install react-native-rfid-nfc-scanner --save

and then link it:

$ react-native link react-native-rfid-nfc-scanner

iOS Configuration

info.plist

add the following to info.plist

<key>NFCReaderUsageDescription</key>
<string>NFC NDEF Reading.</string>

YourAppName.entitlements

The following entry should be created automatically in your YourAppName.entitlements file once you enable NFC capability in your app but if not add the following to YourAppName.entitlements

<dict>
    <key>com.apple.developer.nfc.readersession.formats</key>
    <array>
        <string>NDEF</string>
    </array>
</dict>

Note: If you are having issues getting this to run and you don't have any swift files in your project, just create a new one as simple as this to get the application building with the swift packages (weird bug found while developing)

//
//  SwiftFile.swift
//  MyAppName
//
//  Created by User on Date.
//  Copyright © 2018 Facebook. All rights reserved.

import Foundation

Android Configuration

Take a moment to read this Android documentation about NFC Basics, especially the How NFC Tags are Dispatched to Applications section.

The NFC scanner runs in the foreground for in app scanning.

Edit the file AndroidManifest.xml

Add the permission to read NFC data:

<uses-permission android:name="android.permission.NFC" />

Add the following attribute to your <activity> section to ensure that all NFC intents are delivered to the same activity.

android:launchMode="singleTask"

Example AndroidManifest.xml For Foreground Scanning (In App Scanning)

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.reactnativenfcdemo"
          android:versionCode="1"
          android:versionName="1.0">
    <uses-permission android:name="android.permission.NFC" />
    <uses-sdk
            android:minSdkVersion="16"
            android:targetSdkVersion="22" />
    <application
            android:name=".MainApplication"
            android:allowBackup="true"
            android:label="@string/app_name"
            android:icon="@mipmap/ic_launcher"
            android:theme="@style/AppTheme">
        <activity
                android:name=".MainActivity"
                android:screenOrientation="portrait"
                android:label="@string/app_name"
                android:launchMode="singleTask"
                android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
                android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/nfc_tech_filter" />
        </activity>
    </application>
</manifest>

Usage

There are 2 ways to use this component. You can use the controller or the underlying scanner object.

The NdefRfidScanner class

To use the NfcRfidScanner class import and create one:

import {NfcRfidScanner} from "react-native-rfid-nfc-scanner";

const scanner = new NfcRfidScanner();

scanner.addListener(
    name:String, listenerCallback:Function, errorCallback:Function)

This will register a method and error handler to run when an RFID card is scanned

Scanner API (Using scanner created above)

scanner.init()
  • starts the scanner
scanner.isEnabled()
  • tells you if the device can use an RFID scanner
scanner.getStatus()
  • tells you loading status of the device RFID scanner
scanner.clearListeners()

Accessing original NFC Object (Expanded and unified for use with Android and iOS)

The underlying object this was built on is still accessible with

import NFC from "react-native-rfid-nfc-scanner";

You can still access the NFC api which has also been expanded.

NFC.initialize();
  • Start the scanner (For both android and ios)
NFC.stopScan();
  • Stops the scanner (For android)
NFC.isEnabled();
  • tells you if the device can use an RFID scanner
NFC.checkDeviceStatus();
  • Gets the device status (Described below)
NFC.addListener(name, callback, error);
  • add a scan listener
NFC.removeListener(name);
  • Remove a specific user (Fixed in iOS)
NFC.removeAllListeners();
  • Remove all scan listeners

Statuses

  • waiting - Attempting to start up the NFC scanner
  • ready - Scanner is ready to use
  • missing - The Scanner attempted to start but could not create a reading session
  • unavailable - The scanner is not available on this version of the OS

Response

Upon a successful scan, the callback will recieve a payload in the following format:

{
        "id": "[String] => scan ID",
        "type": "[String] => scan type from device",
        "origin": "[String] => 'ios' or 'android'",
        "scanned": "[String] => scanned data",
        "from_device": "[Object] => payload recieved from the device scan"
}

IOS Response Sample

{
    "id": "unavailable",
    "type": "NFC",
    "encoding": "UTF-8",
    "origin": "ios",
    "scanned": "2033085@MBtilk2XLGLvfxn3edK^qj3Xab/S4B9E92+",
    "from_device": {
        "origin": "ios",
        "data": [
            [
                {
                    "locale": "en",
                    "encoding": "UTF-8",
                    "type": "TEXT",
                    "data": "2033085@MBtilk2XLGLvfxn3edK^qj3Xab/S4B9E92+"
                }
            ]
        ],
        "id": "unavailable",
        "type": "NFC"
    }
}

Android Response Sample

{
    "id": "04E49EFA2E4480",
    "type": "NDEF",
    "encoding": "UTF-8",
    "origin": "android",
    "scanned": "2033085@MBtilk2XLGLvfxn3edK^qj3Xab/S4B9E92+",
    "from_device": {
        "origin": "android",
        "data": [
            [
                {
                    "locale": "en",
                    "encoding": "UTF-8",
                    "type": "TEXT",
                    "data": "2033085@MBtilk2XLGLvfxn3edK^qj3Xab/S4B9E92+"
                }
            ]
        ],
        "id": "04E49EFA2E4480",
        "type": "NDEF"
    }
}

NFC-V/Other Tags on Android

{
    "id": "AD10EA35500104E0",
    "type": "NfcV",
    "encoding": "UTF-8",
    "origin": "android",
    "scanned": "AD10EA35500104E0",
    "from_device": {
        "origin": "android",
        "data": [
            [
                {
                    "id": "AD10EA35500104E0",
                    "description": "TAG: Tech[android.nfc.tech.NfcV, android.nfc.tech.NdefFormatable]",
                    "techList": [
                        "android.nfc.tech.NfcV",
                        "android.nfc.tech.NdefFormatable"
                    ]
                }
            ]
        ],
        "id": "AD10EA35500104E0",
        "type": "TAG"
    }
}

Error Response

If an error handler is provided the response will look like this:

{ "error": "Some error message" }

TODO

  • Support more record types in iOS
  • Support writing tags
  • Advanced NFC operations