@testjg/nativescript-nfc
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

@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

Package Sidebar

Install

npm i @testjg/nativescript-nfc

Weekly Downloads

60

Version

1.1.3

License

Apache-2.0

Unpacked Size

79.4 kB

Total Files

27

Last publish

Collaborators

  • jberga