Search docs/
Getting StartedPlugins

NFC

The NFC plugin allows you to read and write NFC tags. You can also beam to, and receive from, other NFC enabled devices.

Use to

  • read data from NFC tags
  • write data to NFC tags
  • send data to other NFC enabled devices
  • receive data from NFC devices

This plugin uses NDEF (NFC Data Exchange Format) for maximum compatibilty between NFC devices, tag types, and operating systems.

https://github.com/chariotsolutions/phonegap-nfc

Stuck on a Cordova issue?

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Contact Us Today!

Installation

ionic cordova plugin add phonegap-nfcnpm install @ionic-native/nfcnpm install phonegap-nfcnpm install @ionic-native/nfcionic cap sync
Ionic Enterprise comes with fully supported and maintained plugins from the Ionic Team. Learn More or if you're interested in an enterprise version of this plugin Contact Us

Supported Platforms

  • Android
  • BlackBerry 10
  • Windows
  • Windows Phone 8
  • iOS

Usage

Using React?

See here.

import { NFC, Ndef } from '@ionic-native/nfc/ngx';

constructor(private nfc: NFC, private ndef: Ndef) { }

...

// Read NFC Tag - Android
// Once the reader mode is enabled, any tags that are scanned are sent to the subscriber
 let flags = this.nfc.FLAG_READER_NFC_A | this.nfc.FLAG_READER_NFC_V;
 this.readerMode$ = this.nfc.readerMode(flags).subscribe(
     tag => console.log(JSON.stringify(tag)),
     err => console.log('Error reading tag', err)
 );

// Read NFC Tag - iOS
// On iOS, a NFC reader session takes control from your app while scanning tags then returns a tag
try {
    let tag = await this.nfc.scanNdef();
    console.log(JSON.stringify(tag));
 } catch (err) {
     console.log('Error reading tag', err);
 }

For more details on NFC tag operations see https://github.com/chariotsolutions/phonegap-nfc