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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-nfc-rw

v1.0.1

Published

A wrapper to easy to use react-native-nfc-rw.

Downloads

204

Readme

react-native-nfc-rw

npm version npm downloads npm licence Platform

System NFC alert modal can't show on my Android phone, so be this wrapper to easy to use react-native-nfc-manager .

For now, this repo only support NfcV read and write as readNfcVTag and writeNfcVTag .

Install

$ npm install --save react-native-nfc-rw react-native-nfc-manager

iOS

cd ios/ && pod install

In Xcode's Signing & Capabilities tab, add Near Field Communication Tag Reading in Capability , and Xcode will generate <your-project>.entitlement file automatically, if Automatically manage siging is checked, the Identifier and Profile in developer.apple.com will also be modified automatically.

In your info.plist , add

<key>NFCReaderUsageDescription</key>
<string>We need to use NFC</string>

Usage

import React, {Component} from 'react';
import {Button, Modal, StyleSheet, Text, View} from 'react-native';
import {
  destroyNfc,
  initNfc,
  readNfcVTag,
  writeNfcVTag,
} from 'react-native-nfc-rw';

const NFC_YOUR_APP_READ_START_BLOCK = 1;
const NFC_YOUR_APP_WRITE_START_BLOCK = 128;

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      modalNfc: false,
    };
  }

  alertEnableNfc = () => Alert.alert('Remind', 'Please enable NFC of your phone');

  alertNoNfcSupport = () => Alert.alert('Remind', 'NFC is not supported on your phone');

  alertNfcOther = error => console.error('initNfc: ', error);

  // will be invoked on iOS and Android by a button in render()
  showNfcModal = () => {
    initNfc({
      alertEnableNfc: this.alertEnableNfc,
      alertNoNfcSupport: this.alertNoNfcSupport,
      alertNfcOther: this.alertNfcOther,
      onDiscoverTag: this.onDiscoverTag,
      alertIosMessage: 'Let your phone tap the device to add', // for system NFC alert modal on iOS
      alertAndroidOpen: () => this.setState({modalNfc: true}), // for custom NFC alert modal on Android, cause system NFC alert modal can't show on my Android phone,  // default is () => {}
      alertAndroidClose: this.dismissNfcModal, // default is destroyNfc
    });
  };

  // will only be invoked on Android
  dismissNfcModal = () => {
    destroyNfc();
    this.setState({
      modalNfc: false,
    });
  };

  onDiscoverTag = async tag => {
    try {
      let dataRead = await readNfcVTag({
        tag,
        startBlock: NFC_YOUR_APP_READ_START_BLOCK,
        bytesLength: 7, // how many bytes to read from startBlock,default is 4 as one block size
        // forceReadSingleBlock: false, // if true, 4 by 4 bytes when read many bytes,slowest but more compatible
      });

      // ......

      let isOk = await writeNfcVTag({
        tag,
        startBlock: NFC_YOUR_APP_WRITE_START_BLOCK,
        dataToWrite: [1, 9, 4, 9, 10, 1], // bytes array to write from startBlock,if dataToWrite.length % 4 is not 0, will pad 0x00
      });

      if (!isOk) {
        Alert.alert(
          'Write failed',
          'Please tap the device to write NFC',
        );
        return;
      }

    } catch (err) {
      console.error('onDiscoverTag: ', err);
    }
  };

  render() {
    // ......
  }
}