@testjg/nativescript-nfc
by testjg | v1.1.3
Add a plugin description
npm i --save @testjg/nativescript-nfc

@testjg/nativescript-nfc

npm version

Based on the great and more complete: https://github.com/EddyVerbruggen/nativescript-nfc

Installation

ns plugin add @testjg/nativescript-nfc

Usage

Make sure your AndroidManifest.xml includes the permission:

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

In your app code:

import { NfcService } from '@testjg/nativescript-nfc';

export class DemoNfc {
private nfcService = new NfcService();

async startListening() {
const available = await this.nfcService.available();
if (!available) return;

const enabled = await this.nfcService.enabled();
if (!enabled) return;

this.nfcService.setOnNdefDiscoveredListener((nfcData) => console.log('Scanned', nfcData));
}

async stopListening() {
this.nfcService.setOnNdefDiscoveredListener(null);
}
}

License

Apache License Version 2.0