Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@testjg/nativescript-nfc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@testjg/nativescript-nfc
Based on the great and more complete: https://github.com/EddyVerbruggen/nativescript-nfc
Installation
ns plugin add @testjg/nativescript-nfcUsage
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