npm i --save @testjg/nativescript-nfc
- Version: 1.1.3
- GitHub: https://github.com/TestJG/mtmobile-plugins
- NPM: https://www.npmjs.com/package/%40testjg%2Fnativescript-nfc
- Downloads:
- Last Day: 18
- Last Week: 20
- Last Month: 90
@testjg/nativescript-nfc
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